Re: compiler bug: let with name clash

Yann LeCun <[email protected]> Wed, 1 Feb 2006 00:03:18 -0500
Newsgroups gmane.lisp.lush.devel
Organization Courant Institute, NYU
Message-ID <[email protected]>
The compiler expands macros at compile time, not at run
time. Basically, as far as compiled code is concerned, Lush macros
behave pretty much like C/C++ preprocessor macros (which also
expands at compile time).

There is no good way to fix this other than writing 
a brand new compiler that can handle code generation 
at run time.

On the other hand, your "some-func" could itself be a macro....

  -- Yann


On Tuesday 31 January 2006 09:08 pm, Ralf Juengling wrote:
> The example I sent earlier was a bit misleading, since the
> problem does not have to do with let. Try this:
>
> (dm mysum (_ . args)
>      `(+ ,@args) )
>
> (defun some-func (mysum)
>    ((-idx1- (-double-)) mysum)
>    (mysum 0))
>
> (dhc-make () some-func)
>
>
> The problem apparently is that the compiler goes through these
> three stages when compiling a function (function dhc-generate-c):
> 1. macro-expansion in the function body
> 2. parsing and type-checking
> 3. c-code generation
>
> Since it is not known yet in the first stage what bindings get
> established in the scope of the function (formal parameters of the
> function, symbols used in special forms like let, for, etc.), the
> macro-expansion works blindly. It is only in the second stage that
> the bindings are looked at and kept track of with "symbol tables".
> To fix this the macro-expansion must be delayed until the bindings
> are established.
>
> Leon, it looks to me like you are the only one who can fix this in
> a reasonable amount of time. Any hope that you'll take this on soon?
> I'd be happy to help but would need pretty detailed advice.
>
> Thanks,
> Ralf
>
> On Tue, 31 Jan 2006, Ralf Juengling wrote:
> > Here is another incarnation of the problem:
> >
> > (dm mysum (_ . args)
> >    `(+ ,@args) )
> >
> > (defun some-func (mysum)
> >  ((-idx1- (-double-)) mysum)
> >  (let ((s0 (mysum 0)))
> >    ((-double-) s0)
> >    ;; calculate
> >    s0))
> >
> > (dhc-make () some-func)
> >
> > ? (some-func [1 2 3])
> > = 0
> >
> >
> > Could somebody please point me to the code that needs fixing?
> >
> > Thanks,
> > Ralf
> >
> > On Sat, 03 Dec 2005, Ralf Juengling wrote:
> >> Try to compile the code below. 'mysum' gets macro-expanded
> >> by the compiler where it shouldn't.
> >>
> >> ralf
> >>
> >>
> >> (dm mysum (_ . args)
> >>    `(+ ,@args) )
> >>
> >> (defun some-func ()
> >>    (let ((mysum 0))
> >>      ((-double-) mysum)
> >>      ;; calculate
> >>      mysum))
> >>
> >> (dhc-make ()
> >>  	  some-func)
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files for problems?  Stop!  Download the new AJAX search engine that
> > makes searching your log files as easy as surfing the  web.  DOWNLOAD
> > SPLUNK!
> > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> > _______________________________________________
> > Lush-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/lush-devel
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Lush-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/lush-devel



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642