[parenscript-devel] random, mapcar, and loop
Theam Yong Chew
senatorzergling at gmail.com
Fri May 21 23:50:25 UTC 2010
On 5/20/10, Vladimir Sedach <vsedach at gmail.com> wrote:
> Hi Yong,
>
> I've pushed your first two patches. As for random - you're right,
> calling floor on everything is not the right thing to do. OTOH I think
> it's the most used pattern. It's easy enough to write (* number
> (random)) when you really need a random floating point number.
>
> Vladimir
Thanks for committing all the other patches. Seems like your giant
compiler rewrite went pretty well! I have not encountered any other
issues in my generated output. :)
I'm not sure why you removed the floor initially or how it relates to
arrays (that change has been reverted afterwards).
In case it wasn't clear, my original intent was to mimic CLHS on
the input type to RANDOM, which could be either "a positive
integer, or a positive float". The result is either an integer
or float depending on the input. There was additional handling
of the &optional upto (instead of the mandatory
argument to CL:RANDOM) for backward compatibility and
matching to the js Math.Random.
I was motivated by the original ps output not handling float
arguments too well. I'm quite happy to use your suggestion
of (* some-float (random)) for such situations, so perhaps
there was no need for the patch I sent. On the other hand,
that patch is a textbook example of a use case for
define-ps-compiler-macro, if we ever get them :)
Good stuff!
Yong.
PS: Is (funcall (@ ...) ...) to be preferred over ((@ ...) ...) now?
There are still quite a few places with this in the current
source.
More information about the parenscript-devel
mailing list