bugKawa - Bugs: bug #43131, Poor support for re-defining...

 
 

bug #43131: Poor support for re-defining toplevel variables

Submitter:  Helmut Eller <ellerh>
Submitted:  Wed 03 Sep 2014 11:52:44 AM UTC
   
 
Category:  Scheme language Severity:  3 - Normal
Item Group:  Unexpected result Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 15 Sep 2014 07:05:07 PM UTC, comment #3: 

I checked in a fix and the test-case.  Thanks

It does require using the -no-inline flag, at least for now.  Later I'd like to work out some better handling of re-definitions for repls and other interactive develpment. This may include tracking dependencies between functions and recompiling functions if dependencies have chaged.

I may tweak the behavior of --no-inline, but the goal is that it should support more dynamic behavior including redefinitions.  Let me know if you see area where it could be improved.  We may also at some point need a separate flag fo interactive modes separate from -no-inline - not sure yet.

Per Bothner <bothner>
Group administrator
Sat 13 Sep 2014 03:18:43 AM UTC, comment #2: 

I'm working on it.  It's a little tricky because we have to handle multiple threads, deal with constant bindings - and it ties in with the initial bindings of the default environment - which ties in with r7rs imports and defaults.

Per Bothner <bothner>
Group administrator
Fri 05 Sep 2014 07:00:35 AM UTC, comment #1: 

Yes, this kind a re-definition works poorly.  One problem is the interaction with inlining.

Using --no-inline doesn't help - in fact it makes it worse:
version 1: 1
version 2: 1
version 3: 1
version 4: 1
version 5: 1
That seems like a bug which should be investigated.

Because of type propagation etc it difficult for redefinition to work "correctly" in general.  What I'd like to do is implement a "development" mode where we keep the source (or S-expressions) for each function.  We also keep track of dependencies between functions.  Then if f depends on g, and g is redefined or re-compiled, then we also re-compile f.

We should also have a mode where a function can be redefined, as long as the parameter and returns types are compatible.  This can be done without automatic function-level recompilation, as long as we keep the necessary indirection (without inlining).  There is some code for this, but it isn't quite right.  That at least could be fixed moderately easily I think.

Per Bothner <bothner>
Group administrator
Wed 03 Sep 2014 11:52:44 AM UTC, original submission:  

This script

(define (foo) 1)
(define (bar i) (format #t "version ~d: ~s~%" i (foo)) (force-output))
(bar 1)
(define (foo) 2)
(bar 2)
(define foo (lambda () 3))
(bar 3)
(define (foo) 4)
(bar 4)
(define (foo) 5)
(bar 5)


when executed with kawa -r7rs -f test.scm prints:

version 1: 1
version 2: 2
version 3: 2
version 4: 2
version 5: 2


but according to R7RS 5.3.1 "Top level definitions" the result should be:

version 1: 1
version 2: 2
version 3: 3
version 4: 4
version 5: 5



Helmut Eller <ellerh>

 

(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 ellerh (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-09-15 bothner StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2014-09-13 bothner StatusConfirmed In Progress
    2014-09-05 bothner StatusNone Confirmed
        Assigned toNone bothner

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code