[racket] Modified #%top and namespaces

From: Jukka Tuominen (jukka.tuominen at finndesign.fi)
Date: Wed Apr 13 06:14:24 EDT 2011


as part of a visual programming study, I have a piece of code that generates
some GUI controls dynamically based on the number of arguments a procedure
takes. You can input a new procedure, and it will transform the GUI
on-the-fly accordingly.

The problem I have, is that the code works fine without #%top modification,
but with it, the statically and dynamically generated GUI objects cannot see
each other. I assume it's as a namespace issue. I have tried to direct
dynamic evals to current-namespace, but either I do something wrong or the
problem is elsewhere (or several places). AFAIU, the objective is to have
everything happen in a single namespace.

Some relevant parts/examples of the source code:

(define ns (current-namespace))

(define module-arguments-title; created one time only
     (parent module-arguments)
     (style '())
     (enabled #t)
     (vert-margin 0)
     (horiz-margin 0)
     (border 0)
     (spacing 0)
     (alignment (list 'center 'top))
     (min-width 0)
     (min-height 0)
     (stretchable-width #t)
     (stretchable-height #f)))

(define (name stem argument); helper to give names to dynamic gui objects
  (eval-string (string-append "'" stem "-" argument)))

(define (column3 argument); creates objects dynamically n times
     (list 'define (name "horizontal-argument-bar-column3" argument)
            (list 'parent (name "horizontal-argument-bar" argument)); helper
used here
            '(style '())
            '(enabled #t)
            '(vert-margin 0)
            '(horiz-margin 0)
            '(border 0)
            '(spacing 0)
            '(alignment (list 'center 'top))
            '(min-width 0)
            '(min-height 0)
            '(stretchable-width #f)
            '(stretchable-height #t)))

Full source code: (for those with Liitin account)
(liitin:object-properties 'jtu100:object-properties-with-arguments~)

Once working, executing
(jtu100:object-properties-with-arguments~ " ")
and pressing [random content] button repeatedly will generate different
looking argument panel according to the content.

Any ideas how to solve the problem?

br, jukka

|  J U K K A   T U O M I N E N
|  m a n a g i n g   d i r e c t o r  M. A.
|  Finndesign  Kauppiaankatu 13, FI-00160 Helsinki, Finland
|  mobile +358 50 5666290
|  jukka.tuominen at finndesign.fi  www.finndesign.fi

Posted on the users mailing list.