Subject: bug in for on pre59 built with clisp using cygwin
From: Vadim V. Zhytnikov
Date: Mon, 24 Dec 2001 12:25:09 +0300
Thank you for good job!
Yasuaki Honda wrote:
> Dear all,
>
> I have found the reason of the bug that Dan Stanger has encountered.
> This is somewhat a complex bug for which I can propose several solutions.
>
> Let's take an example which will be used through out the explanation.
> for u in [1,2,3] do print(u);
> 1
> 2
> 3
>
> This does not work in clisp2.27 and the latest maxima. Because the
> word 'in' is not properly converted to the symbol $IN.
>
> The function bothcase-implode defined in commac.lisp performs this
> conversion. For the keyword 'in', the conversion takes place in the
> following way: (#(J\(B$ #(J\(Bi #(J\(Bn) -> |$in| -> $IN . The logic in this function
> works only when the symbol |$in| does not exist for the first time this
> function was called with (#(J\(B$ #(J\(Bi #(J\(Bn) as its input. That first time,
> (setf (get sym 'upcase) symup) is executed only if the symbol |$in|
> does not exist. Second time and later when the function is called
> with (#(J\(B$ #(J\(Bi #(J\(Bn) as its input, 'upcase' property is used to do the
> right conversion.
>
> The above condition does hold for symbols such as |$for|, |$do| and
> |$print|. However, it does NOT hold for |$in|. That causes the conversion
> not to work for keyword 'in'. So, who defines this symbol?
>
> If you take a look at mactex.lisp, then you see a function texmdoin
> definition is:
>
> (defun texmdoin (x)
> (nconc `("(J\\(Bmathbf{for}" ,(second x) $|in| ,(third x))
> (cond ((sixth x) `("(J\\(Bmathbf{thru}" ,(sixth x))))
> (cond ((null (seventh x)) nil)
> ((eq 'mnot (caar (seventh x)))
> `("(J\\(Bmathbf{while}" ,(cadr (seventh x))))
> (t `("(J\\(Bmathbf{unless}" ,(seventh x))))
> `("(J\\(Bmathbf{do}" ,(eighth x))))
>
> You see a symbol $|in| there in the definition. This symbol is same as
> |$in|. This means that once mactex.{lisp,fas} is read, the symbol starts
> to exist. To confirm, you may change $|in| to something like |$anything|
> and reload the file. Then the example
> for u in [1,2,3] do print(u);
> does work fine. (Oh, of course this is not a solution since generated tex
> source will be mangled.)
>
> So, some solutions are:
> (1) to modify texmdoin in mactex.lisp to avoid using a lisp symbol to
> generate a TeX source text. It should be achievable only using strings.
>
> (2) to modify bothcase-implode in commac.lisp so that it does not care
> the prior existence of a symbol such as |$in|.
>
> (3) In some place, just execute (setf (get '|$in| 'upcase) '$IN) so that
> the logic in bothcase-implode works and conversion takes place.
>
> I would suggest (3) for a temporary solution and do a serious rewrite
> of bothcase-implode function later at some time. Any suggestions?
>
I definetely prefere (2) but it might be tricky. And the hard part is not
the function itself but confidence that our modification do not
break some other piece of code. So maybe (3) is indeed
acceptable as temporary solution.
>
> Some note:
> - Though bessel.lisp defines function name $in, the symbol $in and
> |$in| are different and bessel.lisp has nothing to do with this bug.
>
> - Vadim V. Zhytnikov has pointed out that GCL performs things well.
> This may have something to do with the how common lisp symbol
> intern works on GCL and clisp. Since I don't have GCL at hand and
> Mac OS X is not a supported platform for GCL, I cannot test it.
> It would be of some help if someone do:
> (eql '|$in| '$|in|)
> and tell me the result.
This gives T on both clisp and GCL.
>
>
> Yasuaki Honda
> Chiba, Japan.
>
> On 2001.12.23, at 22:43, Vadim V. Zhytnikov wrote:
>
> > This is certainly clisp specific bug. With gcl
> > all variants
> > for ... in ...
> > for ... IN ...
> > for ... iN ...
> > for ... In ...
> > work fine.
> >
> > Yasuaki Honda wrote:
> >
> >> Dear Dr. Dan Stanger,
> >>
> >> I just noticed that:
> >> for u IN x do print(u);
> >> works fine while
> >> for u in x do print(u);
> >> does not.
> >>
> >> Capitalizing both letters looks important. Certainly this should be
> >> a bug...
> >>
> >> Yasuaki Honda
> >> Japan
> >>
> >> On 2001.12.20, at 10:22, Dan Stanger wrote:
> >>
> >>> f(x):=for u in x do print(u); give the following error message:
> >>> Incorrect syntax: in is an unknown keyword in a DO statement.
> >>>
> >>> This works correctly in previous versions.
> >>> Dan Stanger
> >>>
> >>> _______________________________________________
> >>> Maxima mailing list
> >>> Maxima@www.math.utexas.edu
> >>> http://www.math.utexas.edu/mailman/listinfo/maxima
> >>>
> >>
> >> _______________________________________________
> >> Maxima mailing list
> >> Maxima@www.math.utexas.edu
> >> http://www.math.utexas.edu/mailman/listinfo/maxima
> >
> > --
> >
> > [ Vadim V. Zhytnikov <vvzhy@mail.ru> <vvzhy@td.lpi.ac.ru> ]
> >
> >
> >
> >
> > _______________________________________________
> > Maxima mailing list
> > Maxima@www.math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
> >
--
[ Vadim V. Zhytnikov <vvzhy@mail.ru> <vvzhy@td.lpi.ac.ru> ]