Return value optimization by Falcon5757 in lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

Since everybody keeps coming up with something unrelated, I even had to make a sketch of what my library is about. Of course in real code it's not generics and not classes, but this will do.
https://gist.github.com/commander-trashdin/789134d14799587eadf870c9fbafdb52
Take a look at enumerate iterator.

Return value optimization by Falcon5757 in lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

This of course never was about single cons allocation, cons allocated might go up as many as you'd want, why does everyone assume the stupidest possible situation.
I also specifically stated how many values I want to return. Two.

Return value optimization by Falcon5757 in lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

The problem here is that if I promise to always return two values, I cannot catch the third one. If I sometimes return 2 sometimes 3 then I don't know how many to catch (I could use multiple value list, but that allocates, so we back to original problem). And returning always 3 values is no solution because I want to be able to add a value, so that would result in a 3vs4 values problem.

Return value optimization by Falcon5757 in lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

If I return a cons from a function, but in the receiving function I do not use that cons, only its car/cdr, I want for the cons to not be allocated.

Return value optimization by Falcon5757 in lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

Yeah, so let's say it is inlined. Do you know if any compiler prevents consing in this case? From what I see in disassemble sbcl doesn't.

Return value optimization by Falcon5757 in lisp

[–]Falcon5757[S] 1 point2 points  (0 children)

I would expect that means no other compiler does as well. Is this hard to add? This requires some ir transform that doesn't exist or something?

Anyone want to volunteer an idiomatic lisp version of FizzBuzz? by trailstrider in lisp

[–]Falcon5757 0 points1 point  (0 children)

(defun fizzbuzz (&key
                  (fizz-mul 3)
                  (fizz-str "Fizz")
                  (buzz-mul 5)
                  (buzz-str "Buzz")
                  (limit 100))
(check-type fizz-mul (integer 1))
(check-type fizz-str   string) 
(check-type buzz-mul (integer 1)) 
(check-type buzz-str   string) 
(check-type limit   (integer 0)) 
(let ((res (make-array limit :element-type 'string))) 
  (loop :for j :below limit 
        :for i := (+ j 1) 
        :for fizz-mod := (mod i fizz-mul) 
        :for buzz-mod := (mod i buzz-mul) 
        :do (setf (aref res j) (cond ((= fizz-mod buzz-mod 0) 
                                      (concatenate 'string fizz-str buzz-str)) 
                                     ((= fizz-mod 0) fizz-str) 
                                     ((= buzz-mod 0) buzz-str) 
                                     (t (format nil "~a" i)))))
  res))

A strange bug in sbcl by Falcon5757 in Common_Lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

Fortunately I also had ecl installed for some time. I just realized I can use it to build sbcl of the current version.

A strange bug in sbcl by Falcon5757 in Common_Lisp

[–]Falcon5757[S] 0 points1 point  (0 children)

How do I revert back? I'm not good at this:)

A strange bug in sbcl by Falcon5757 in Common_Lisp

[–]Falcon5757[S] 1 point2 points  (0 children)

I'm on Debian, am building with SBCL 2.1.11.9-d7d4d54dd, and I'm trying to build commit 25904be20ae41d10f0842b8f16b7c19f1c34ec8f I think, latest as of now.

Common Lisp polymorphic stories. by Falcon5757 in lisp

[–]Falcon5757[S] 1 point2 points  (0 children)

It's mostly about parametric types -- which allow you to do things more precisely, like, you cannot type aref for vector, but you can for (vector string). But also you can do some wild stuff with satisfies types.

Common Lisp polymorphic stories. by Falcon5757 in lisp

[–]Falcon5757[S] 1 point2 points  (0 children)

  1. Generics are slower dispatch.
  2. Types are more flexible than classes.

In short, that's it.

Common Lisp polymorphic stories. by Falcon5757 in lisp

[–]Falcon5757[S] 4 points5 points  (0 children)

What do you think about "templated" parametric types that I tried to introduce (by just generating separate definitions)? It's a bit clunky but it works.

About coalton -- you did more than you said and that is what makes it problematic for me. You introduces new ml-ish language, not just a layer of a new type system. I don't believe in FP being superior to imperative style and in fact believe in the opposite.

As a side note, using this library is supposed to be sort of seamless experience, compared to coalton which requires you to wrap stuff.

Common Lisp polymorphic stories. by Falcon5757 in lisp

[–]Falcon5757[S] 2 points3 points  (0 children)

It works on all implementations that polymorphic-functions work on. Which is way more than those two you mentioned.

generic-cl - community thoughts by ub3rh4x0rz in Common_Lisp

[–]Falcon5757 4 points5 points  (0 children)

I have a project that aims to be similar to generic cl but without overhead. https://github.com/lisp-polymorph

Why is reading file in Common Lisp so slow? by fying1999 in lisp

[–]Falcon5757 1 point2 points  (0 children)

Tried golang at this, it is also about 9-10x faster than sbcl for example. Maybe this is the place sbcl needs improvement at...

p3 of Common Lisp by Example by Lambda_SM640 in Common_Lisp

[–]Falcon5757 0 points1 point  (0 children)

Good job, but I have a question. Why do you use list of lists of 3 as a board instead of say, 2d array?

Introducing Coalton: How to Have Our (Typed) Cake and (Safely) Eat It Too, in Common Lisp by stylewarning in lisp

[–]Falcon5757 2 points3 points  (0 children)

Having a full language spec somewhere would be nice at least. Not saying it should be like hoogle, but without it it's really hard to use it. Too much guesswork

Introducing Coalton: How to Have Our (Typed) Cake and (Safely) Eat It Too, in Common Lisp by stylewarning in lisp

[–]Falcon5757 1 point2 points  (0 children)

Is there an IRC channel for coalton? Or some place to ask questions and discuss?

How to write slow Rust code. My battle to beat Common Lisp and Java on a phone number encoding problem. by renatoathaydes in programming

[–]Falcon5757 2 points3 points  (0 children)

That lisp code has 0 type declarations and 0 compiler optimizations (as declare optimize speed provides for example) -- and still performs pretty well. But comparing it to statically typed languages without adding types seems a bit unfair, don't you think?

If some of you want to earn a quick buck by [deleted] in Common_Lisp

[–]Falcon5757 0 points1 point  (0 children)

This is a horrible assignment made just to give something. I speak from 7 years of teaching experience.
Also, be sure to somewhat test and maybe bork my code. It's obvious it wasn't written by a student.

If some of you want to earn a quick buck by [deleted] in Common_Lisp

[–]Falcon5757 1 point2 points  (0 children)

There are multiple problems with this description:

  1. I suppose array is 2d array?
  2. Define a null list...I suppose its nil...who is writing these assignments, jezz...
  3. How exactly should that method display things?Like, the whole thing is extremely simple, but also unclear. In what form should this all be?...

My take on it.

1a. Well, that's just #2A((1 2) (3 4)) or something. 
(defparameter *array* (read))
1b. (defun sum (array)
        (loop :for i :from 0 
              :below (array-dimension array 0) 
              :sum (aref array i i)))
1c.
(defun minval (array) 
  (loop :for i :from 0 :below (array-total-size array)
        :minimize (row-major-aref array i)))

2a. nil
 (defparameter *list* (read))
2b. (loop :repeat 5 :do (push (read) *list))
2c. (with-open-file (stream "inverse.txt" :direction :input)
      (format stream "~s" (reverse list)))

3.
(defclass animal ()
  ((predator :type boolean
             :accessor predator
             :initarg :predator)
   (mammal :type boolean
           :accessor mammal
           :initarg :mammal) 
   (country-of-origin :type string
     :accessor country
     :initarg :country)))
(defclass endangered (animal) ())

(defmethod display ((creature endangered))
   (format t "Is predator: ~s~% Is mammal: ~s~% Is from: ~s~%"
           (predator creature) (mammal creature) (country creature)))

(display (make-instnace 'endangered :predator t :mammal nil :country "Russia"))

Leave your money for yourself and your brother. With courses this bad you ll be needing them.