bugKawa - Bugs: bug #47433, Strange Environment when kawa.repl...

 
 

bug #47433: Strange Environment when kawa.repl is passed a file without -f

Submitted by:  Tom Bousso <tbousso>
Submitted on:  Wed 16 Mar 2016 11:30:14 PM UTC  
 
Category: Scheme librarySeverity: 3 - Normal
Item Group: Unexpected resultStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 16 Mar 2016 11:54:50 PM UTC, comment #1:

Scheme's concept of "top-level environment" is a weird beast, and doesn't really mix well with the R6RS/R7RS idea of modules/libraries. If you don't use -f, then the file is an "implicit module", and the define is lexical. It doesn't automatically get put in the dynamic environment. It may get added to the dynamic environment when the module is required/imported, as part of the magic to deal with the REPL.
Read the "Modules and how they are compiled to classes" for lots more detail than you probably want.

In general, try avoid using environment-bound?, the dynamic environment, eval, or load (as opposed to import or require). If you do, the code will be cleaner, faster and the compiler can catch errors more easily. Of course those features have their uses, but people thend to way overuse them.

If you really need to define a variable in the dynamic environment, use define-variable instead of plain define. Note that define-variable has limited use, but can be suitable for dynamic binding and fluid-let.

Per Bothner <bothner>
Project Administrator
Wed 16 Mar 2016 11:30:14 PM UTC, original submission:

test.scm
(define a 3)
(display (environment-bound? (gnu.mapping.Environment:getCurrent) 'a))

This script prints #t if evaluated using "java kawa.repl -f test.scm" but it prints #f if evaluated using just "java kawa.repl test.scm". I'm confused as to how this could print #f while a maintains its value properly.

I debugged it until runFile in Shell.java which is called with lineByLine as true if "-f" is used and false if it isn't.

Tom Bousso <tbousso>

 

(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 tbousso (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):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 08 Apr 2016 05:19:28 PM UTCbothnerOpen/ClosedOpen=>Closed
    Wed 16 Mar 2016 11:54:50 PM UTCbothnerStatusNone=>Invalid

    Back to the top


    Powered by Savane 3.1-cleanup1