bugKawa - Bugs: bug #19262, top-level define scope violation

 
 

bug #19262: top-level define scope violation

Submitted by:  Aubrey Jaffer <jaffer>
Submitted on:  Fri 09 Mar 2007 08:03:42 PM UTC  
 
Category: Scheme languageSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: None
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sun 01 Apr 2007 06:42:40 AM UTC, comment #6:

I checked into SVN some fixes to colon-handling.
If there are still colon-related problems, could you send me a test-case with instructions?

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 29 Mar 2007 05:24:43 PM UTC, comment #5:

> I will recode them if Kawa can get past the colon problem.


I'm working on fixing one set of colon-related problems.
I think these only affect local variables with colons, but we'll try again as soon as I have checked in a fix.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 29 Mar 2007 02:12:11 AM UTC, comment #4:

| Follow-up Comment #3, bug #19262 (project kawa):
|
| > Binding identifiers to themselves is a way of capturing their
| > values at definition time. Take a look at the SLIB quick-printer
| > (qp.scm)
|
| But we're talking about multiple definitions of the same name in
| the same scope. That's completely different from what qp does.

Oh, I see. But "Capturing the load-time value of a procedure being
wrapped"
http://groups.google.com/group/comp.lang.scheme/browse_frm/thread/88d262c1e60da5cc/bd1e11ae45da615e?lnk=st&q=Capturing+the+load-time+value+of+a+procedure+being+wrapped&rnum=1#bd1e11ae45da615e
is valid in R5RS.

I have recoded such wrappers in "require.scm" and "mularg.scm":

* require.scm (slib:report, slib:report-locations): Changed shadow
bindings to not duplicate top-level names.
* mularg.scm (/, -): Removed gratuitous shadow binding.

"trnscrpt.scm" and "trnscrpt.scm" also have such wrappers. I will
recode them if Kawa can get past the colon problem.

Aubrey Jaffer <jaffer>
Mon 26 Mar 2007 12:10:50 AM UTC, comment #3:

> Binding identifiers to themselves is a way of capturing their values at definition time. Take a look at the SLIB quick-printer (qp.scm)


But we're talking about multiple definitions of the same name in the same scope. That's completely different from what qp does.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Sun 25 Mar 2007 11:24:45 PM UTC, comment #2:

| From: Per Bothner <INVALID.NOREPLY@gnu.org>
| Date: Mon, 19 Mar 2007 06:03:15 +0000
|
| This kind of code doesn't work well with Kawa's attempt to resolve
| names to declarations at compile time. I don't think such code
| really makes much sense - it certainly is pretty bad stylle.

Certainly? I don't think so!

Binding identifiers to themselves is a way of capturing their values
at definition time. Take a look at the SLIB quick-printer (qp.scm)
http://cvs.savannah.gnu.org/viewcvs/slib/slib/qp.scm?view=markup,
which captures all the procedures it calls so that it won't infinite
loop when tracing builtin procedures.

Qp without these bindings is much less useful. What would you
consider good style; making a new name for each captured identifier?
That would certainly reduce the readability of the code and be no
safer.

| That said, Kawa's handling of the "Scheme top-level" is something
| I'm currently looking at. The current behavior in SVN isn't
| something I'm happy about. This is related to the handling of
| "load", which also doesn't work well with a static compilation
| model, and which I also need to consider.
|
| But apart from the "Kawa way" of doing things, there should be a
| way of getting a more traditional dynamic Scheme interface.
| Basically, this would be disabling certain kinds of "inlining".
| There is a --no-inline flag; I should perhaps make sure that the
| test case works under that option.

Your compiler should recognize define-time bindings as "closing the
world" over those bindings. They represent an opportunity to inline
the bound procedures (because their value can't change).

Aubrey Jaffer <jaffer>
Mon 19 Mar 2007 06:03:14 AM UTC, comment #1:

This kind of code doesn't work well with Kawa's attempt to resolve names to declarations at compile time. I don't think such code really makes much sense - it certainly is pretty bad stylle.

That said, Kawa's handling of the "Scheme top-level" is something I'm currently looking at. The current behavior in SVN isn't something I'm happy about. This is related to the handling of "load", which also doesn't work well with a static compilation model, and which I also need to consider.

But apart from the "Kawa way" of doing things, there should be a way of getting a more traditional dynamic Scheme interface. Basically, this would be disabling certain kinds of "inlining". There is a --no-inline flag; I should perhaps make sure that the test case works under that option.

I do need to fix some problems with define-class first, and then the next priority is dealing with top-level names and load.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Fri 09 Mar 2007 08:03:42 PM UTC, original submission:

New test in r4rstest.scm:

(define foo (lambda () 9))
(test 9 'define (foo))
(define foo foo)
(test 9 'define (foo))
(define foo (let ((foo foo)) (lambda () (+ 1 (foo)))))
(test 10 'define (foo))

fails at the last line with:

java.lang.NullPointerException
at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:220)
at gnu.mapping.ProcedureN.apply1(ProcedureN.java:31)
at atInteractiveLevel$107.lambda1(r4rstest.scm:255)
at atInteractiveLevel$107.apply0(r4rstest.scm:255)
at gnu.expr.ModuleMethod.apply0(ModuleMethod.java:176)
at gnu.expr.ModuleMethod.apply(ModuleMethod.java:150)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
at gnu.expr.Expression.eval(Expression.java:24)
at gnu.expr.ApplyExp.apply(ApplyExp.java:63)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:205)
at kawa.Shell.run(Shell.java:230)
at kawa.standard.load.loadSource(load.java:110)
at kawa.standard.load.apply(load.java:210)
at kawa.standard.load.apply2(load.java:147)
at kawa.standard.load.apply1(load.java:138)
at gnu.mapping.Procedure.apply(Procedure.java:112)
at gnu.mapping.Procedure.apply(Procedure.java:95)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:296)
at kawa.Shell.run(Shell.java:230)
at kawa.Shell.run(Shell.java:172)
at kawa.Shell.run(Shell.java:159)
at kawa.repl.main(repl.java:844)

Aubrey Jaffer <jaffer>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  • -unavailable- added by jaffer (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 19 Mar 2007 06:03:14 AM UTCbothnerAssigned toNone=>bothner

    Back to the top


    Powered by Savane 3.1-cleanup