[Openmcl-devel] Mark Kantrowitz infix.lisp easter egg?
gb at clozure.com
Sat Dec 3 08:22:59 UTC 2011
That's part of the problem. The parser tries to read:
(<valid-number><exponent-marker> <sign> <integer>)
as a float in (infix) scientific notation (sorta ...). What I'm calling
a <valid-number> is apparently supposed to be a string of decimal digits
containing at most one dot; the function INFIX::VALID-NUMBERP considers
the empty string to match, so things like (s + 1) get turned into S+1.
If you change VALID-NUMBERP to not consider empty strings to be valid numbers,
? (values (read-from-string "#i(s + 1)"))
(+ S 1)
I don't know whether or not the (very old) code contains other similar
problems; the fact that it's been around as long as it has doesn't
seem to have anything to do with that.
On Fri, 2 Dec 2011, Joshua TAYLOR wrote:
> On Fri, Dec 2, 2011 at 8:56 PM, Alexander Repenning
> <ralex at cs.colorado.edu> wrote:
>> Using?Mark Kantrowitz?old but very handy infix we noticed some peculiar
>> pattern of errors where very basic expressions do not correctly convert
>> infix expressions into prefix ones. The version I just tried was this
>> in => pre, red for incorrect
>> "a + 1" ? =>?(+ A 1)
>> "s + 1" ? => ?S+1
>> "s - 1" ? => ?S-1
>> "s * 1" =>?(* S 1)
>> "a + 1.5"? => (+ A 1.5)
>> "s + 1.5"? =>?(+ S 1.5)
>> "s + s" =>?(+ S S)
>> "s + 1 + 1" =>?(+ S+1 1)
>> "s + 1e1" =>?(+ S 10.0)
>> Can somebody see a pattern here? AFAIK, the combination of the one letter
>> variables names that are characters D, E, F, L, or S followed by "+" or "-"
>> and then followed by an int does not work.
> Didn't look into the code, but those letters are special?
> CL-USER 15 > (list 1.0d+0 1.0d-0
> 1.0e+10 1.0e-10
> 1.0f+0 1.0f-0
> 1.0l+0 1.0f-0
> 1.0s+0 1.0s-0)
> (1.0D0 1.0D0 1.0E10 1.0E-10 1.0 1.0 1.0D0 1.0 1.0S0 1.0S0)
> Joshua Taylor, http://www.cs.rpi.edu/~tayloj/
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel