Re: off topic, Re: [racket-users] Defining a symbol breaks symbols?

2015-10-08 Thread Lyle Kopnicky
Yes, sorry, I've been traveling and didn't have time to respond. I was
originally tempted to say "statically typed" and then realized that wasn't
exactly right, because it was not static types that would forbid such a
construction, so I said "static languages" suggesting languages where
things cannot be so easily changed.

I'm not so familiar with reader macros. The documentation looks pretty
extensive so I don't have to time to absorb it right now. I would imagine
that macros are not closures, therefore they shouldn't have any free
variables. But perhaps that's an oversimplification, and there are cases
where you need to write a macro to generate some expression with free
variables in it. I guess at the time that the macro is expanded, it must
find the right bindings for the variables.

Matthew Flatt gave a nice demonstration of a clean way to do that (using
multiple scopes with colors). I'm not sure how things might be different
for reader macros, though. It seems to me that while the input of a reader
macro is different (plain text instead of sexprs), the output is still
sexprs, so the same sort of scoping rules should apply.

On Fri, Oct 2, 2015 at 6:56 AM, Matthias Felleisen 
wrote:

>
>
> On Oct 2, 2015, at 9:50 AM, "John B. Clements" 
> wrote:
>
> >
> >> On Sep 30, 2015, at 2:57 PM, Matthias Felleisen 
> wrote:
> >>
> >>
> >> On Sep 30, 2015, at 4:19 PM, Lyle Kopnicky  wrote:
> >>
> >>> I'm used to static languages lately and it's been a long time since
> I've programmed in a Lisp.
> >>
> >>
> >> With respect, what could the word "static" possibly mean here?
> >
> > In my mind, here, “static” == “a language in which it’s not possible to
> re-bind the meaning of a primitive like ‘quote’.” No?
>
>
>
> https://existentialtype.wordpress.com/2014/04/21/bellman-confirms-a-suspicion/

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: off topic, Re: [racket-users] Defining a symbol breaks symbols?

2015-10-08 Thread Alex Knauth

> On Oct 8, 2015, at 9:00 AM, Lyle Kopnicky  wrote:
> 
> Yes, sorry, I've been traveling and didn't have time to respond. I was 
> originally tempted to say "statically typed" and then realized that wasn't 
> exactly right, because it was not static types that would forbid such a 
> construction, so I said "static languages" suggesting languages where things 
> cannot be so easily changed.

Ok I think I see what you're saying. Unhygienic macros capture bindings from 
the use site, which breaks lexical scope and brings it closer to looking like 
dynamic scope, and unhygienic reader extensions do the same thing. But that's 
why we have hygienic macros and hygienic reader extensions; to restore lexical 
scope, which is static.

> I'm not so familiar with reader macros. The documentation looks pretty 
> extensive so I don't have to time to absorb it right now.

Reader extensions are not my favorite part of racket. Whenever I make them, 
they feel like a bit of a mess.

> I would imagine that macros are not closures, therefore they shouldn't have 
> any free variables.

Half the point of hygienic macros is that they can "close over" variables that 
would otherwise appear to be free variables, but are actually bound to some 
variable in the context of the macro definition instead of the context of the 
macro use site. So they can act like closures. And it's in that analogy of 
hygienic macros as closures that unhygienic macros look like dynamic scope. But 
hygienic macros can "close over" these things to restore lexical scope. 

Hygienic reader extensions can do the same thing, although there can be some 
complications with an identifier being bound to an identifier that is not 
available anywhere that the use site module knows about. So for instance the 
afl meta-language expands to lambda from racket/base, but it only works when 
the base language depends in some way on racket/base. That base language 
doesn't need to provide the lambda from racket/base, but a dependency has to be 
there somewhere. That isn't a lot to ask, but it does means that for instance 
#lang afl racket/kernel won't work.

Matthew Flatt explained to me that for normal macros, this is handled 
automatically, but not for reader extensions.

> Matthew Flatt gave a nice demonstration of a clean way to do that (using 
> multiple scopes with colors). I'm not sure how things might be different for 
> reader macros, though. It seems to me that while the input of a reader macro 
> is different (plain text instead of sexprs), the output is still sexprs, so 
> the same sort of scoping rules should apply.

For hygienic macros to avoid this capturing behavior, there has to be a color 
at the use site of the macro that is not in the context of the definition of 
the macro. This is handled automatically by default.

For hygienic reader extensions, the same principle applies, but you have to do 
that yourself because it's not handled automatically. Also, there has to be a 
dependency somewhere on the module that provides the identifier, which is 
another thing macros handle automatically and reader extensions don't.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


off topic, Re: [racket-users] Defining a symbol breaks symbols?

2015-10-02 Thread Matthias Felleisen


On Oct 2, 2015, at 9:50 AM, "John B. Clements"  
wrote:

> 
>> On Sep 30, 2015, at 2:57 PM, Matthias Felleisen  wrote:
>> 
>> 
>> On Sep 30, 2015, at 4:19 PM, Lyle Kopnicky  wrote:
>> 
>>> I'm used to static languages lately and it's been a long time since I've 
>>> programmed in a Lisp.  
>> 
>> 
>> With respect, what could the word "static" possibly mean here? 
> 
> In my mind, here, “static” == “a language in which it’s not possible to 
> re-bind the meaning of a primitive like ‘quote’.” No?


https://existentialtype.wordpress.com/2014/04/21/bellman-confirms-a-suspicion/

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.