Yes. Yes, that exactly solves my problem. *sheepish look* Thanks.
On Tue, Aug 9, 2016 at 8:47 PM, Matthew Butterick wrote:
>
> On Aug 9, 2016, at 7:52 PM, David Storrs wrote:
>
> > This solves the problem of creating top-level bindings at run time (more
> or less run time, anyway), but it d
On Aug 9, 2016, at 7:52 PM, David Storrs wrote:
> This solves the problem of creating top-level bindings at run time (more or
> less run time, anyway), but it doesn't handle the lexical closure part. Is
> there a way to do that?
The code generated by a macro automatically adopts the lexical
On Tue, Aug 9, 2016 at 2:20 PM, John Clements
wrote:
>
> Racket is essentially a lexically scoped language. That is: it should be
> possible to look at a piece of code and figure out where the binding for a
> given variable is. It does have a dynamic binding mechanism, but the names
> that are bo
On Tue, Aug 9, 2016 at 2:35 PM, Ben Greenman
wrote:
> Here's something in the ballpark.
>
> #lang racket
>
> (define-namespace-anchor nsa)
> (define ns (namespace-anchor->namespace nsa))
>
> (let ((xyz 1))
> (for ((name '(x y z)))
> (namespace-set-variable-value! name (lambda () (displayln
Here's something in the ballpark.
#lang racket
(define-namespace-anchor nsa)
(define ns (namespace-anchor->namespace nsa))
(let ((xyz 1))
(for ((name '(x y z)))
(namespace-set-variable-value! name (lambda () (displayln (format "~a:
~a" name xyz)) (set! xyz (add1 xyz))) #f ns)))
(eval '(x)
> On Aug 9, 2016, at 4:46 PM, David Storrs wrote:
>
> In Perl it's possible to generate main-namespace functions like so:
>
> perl -E 'my $z = 1; for (qw/foo bar baz/) {my $x = $_; *$_ = sub{ say "$x: ",
> $z++ }}; foo(); bar(); baz();'
>
> This outputs:
> foo: 1
> bar: 2
> baz: 3
>
>
> No
In Perl it's possible to generate main-namespace functions like so:
perl -E 'my $z = 1; for (qw/foo bar baz/) {my $x = $_; *$_ = sub{ say "$x:
", $z++ }}; foo(); bar(); baz();'
This outputs:
foo: 1
bar: 2
baz: 3
Note that it is generating top-level subroutines that can be called from
elsewhere
7 matches
Mail list logo