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

 
 

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

Submitter:  Tom Bousso <tbousso>
Submitted:  Wed 16 Mar 2016 11:30:14 PM UTC
   
 
Category:  Scheme library Severity:  3 - Normal
Item Group:  Unexpected result Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-08 bothner Open/ClosedOpen Closed
    2016-03-16 bothner StatusNone Invalid

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code