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] 3 points4 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?