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

2015-10-19 Thread Alex Knauth
Would you expect anything different if it were a normal macro?

#lang racket

(define-syntax-rule (define-quote (arg ...) expr)
  (define (quote arg ...) expr))

(define-quote (x) 5)
(define-quote (x) 5)
(quote 3)

This also compiles without error, and also returns 3. Were you expecting a 
hygienic reader extension to behave differently?


> On Oct 18, 2015, at 9:03 AM, Gustavo Massaccesi  wrote:
> 
> I found a strange side effect of the use of the marks. This compiles
> without error:
> 
> #lang hygienic-quote racket
> 
> (define 'x 5)
> (define 'x 5)
> '3
> 
> But I think it's not a problem for real word use, and it's better than
> the standard behavior.
> 
> Gustavo


-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-10-18 Thread Alex Knauth

> On Oct 18, 2015, at 9:03 AM, Gustavo Massaccesi  wrote:
> 
> This "breaks" my old example:
> 
> #lang hygienic-quote racket
> (define-syntax-rule (quasiquote x) (reverse 'x))
> `(1 2 3 4)
> 
> Nice idea!
> 
> I found a strange side effect of the use of the marks. This compiles
> without error:
> 
> #lang hygienic-quote racket
> 
> (define 'x 5)
> (define 'x 5)
> '3

Yes I did that on purpose.

I do that here:
https://github.com/AlexKnauth/hygienic-quote-lang/blob/master/hygienic-quote/reader.rkt#L80
 


For that I had to create two scopes. One for the outside, which the quote 
identifier would not have at the end, and one for each inside, which the quote 
identifier would have but nothing else would. This inner scope is different for 
every use of the reader extension, just like it would be for each use of a 
regular macro.


> But I think it's not a problem for real word use, and it's better than
> the standard behavior.
> 
> Gustavo
> 
> On Fri, Oct 16, 2015 at 12:32 AM, Alex Knauth  wrote:
>> Sorry it took so long, but I just finished making a meta-language that adds
>> quote, quasiquote, etc. as hygienic reader extensions.
>> 
>> https://github.com/AlexKnauth/hygienic-quote-lang
>> 
>> So now, you can write
>> 
>> #lang hygienic-quote racket
>> 
>> To make sure that the ' character will always be bound to the quote from
>> racket/base, not some weird thing that you accidentally defined. It also
>> does this for quasiquote, unquote, unquote-splicing, syntax, quasisyntax,
>> unsyntax, and unsyntax-splicing.


-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-10-18 Thread Gustavo Massaccesi
This "breaks" my old example:

#lang hygienic-quote racket
(define-syntax-rule (quasiquote x) (reverse 'x))
`(1 2 3 4)

Nice idea!


I found a strange side effect of the use of the marks. This compiles
without error:

#lang hygienic-quote racket

(define 'x 5)
(define 'x 5)
'3

But I think it's not a problem for real word use, and it's better than
the standard behavior.

Gustavo




On Fri, Oct 16, 2015 at 12:32 AM, Alex Knauth  wrote:
> Sorry it took so long, but I just finished making a meta-language that adds
> quote, quasiquote, etc. as hygienic reader extensions.
>
> https://github.com/AlexKnauth/hygienic-quote-lang
>
> So now, you can write
>
> #lang hygienic-quote racket
>
> To make sure that the ' character will always be bound to the quote from
> racket/base, not some weird thing that you accidentally defined. It also
> does this for quasiquote, unquote, unquote-splicing, syntax, quasisyntax,
> unsyntax, and unsyntax-splicing.
>
> It only works with the the new scope-set expander right now, although I
> could probably tweak it so that it works for both.
>
>
> On Oct 8, 2015, at 11:31 AM, Alex Knauth  wrote:
>
>
> 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.

-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-10-15 Thread Alex Knauth
Sorry it took so long, but I just finished making a meta-language that adds 
quote, quasiquote, etc. as hygienic reader extensions.

https://github.com/AlexKnauth/hygienic-quote-lang 


So now, you can write

#lang hygienic-quote racket

To make sure that the ' character will always be bound to the quote from 
racket/base, not some weird thing that you accidentally defined. It also does 
this for quasiquote, unquote, unquote-splicing, syntax, quasisyntax, unsyntax, 
and unsyntax-splicing.

It only works with the the new scope-set expander right now, although I could 
probably tweak it so that it works for both.


> On Oct 8, 2015, at 11:31 AM, Alex Knauth  wrote:
> 
> 
>> 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.


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.


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

2015-10-02 Thread 'John B. Clements' via Racket Users

> 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?

John




-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-09-30 Thread Jens Axel Søgaard
2015-09-30 19:35 GMT+02:00 Lyle Kopnicky :

> Hi folks,
>
> It seems that if I (incorrectly) quote a symbol in a 'define' form, it
> breaks all symbols from that point on. I would expect instead it would give
> me an error saying that I passed the wrong sort of thing to 'define', and
> not break future use of symbols. Is this a bug?
>
> Welcome to DrRacket, version 6.2.1 [3m].
> Language: racket; memory limit: 128 MB.
> > 'foo
> 'foo
>

Note that 'foo is short for (quote foo).


> > 'bar
> 'bar
> > (define 'foo 5)
>

This is the same as

(define (quote foo) 5)

which means that you are defining a function named quote that when called
with one argument returns the number 5.


> > 'foo
> . . foo: undefined;
>

This means

(quote foo)

i.e. you are now calling the (newly defined) quote function - but the
argument foo is not defined - hence the error.


>  cannot reference an identifier before its definition
> > 'bar
> . . bar: undefined;
>  cannot reference an identifier before its definition
> >
>

Try

> '3
5

The lesson here is that at the top-level (in the REPL) it is possible to
redefine builtin syntax.

Here the shorthand ' makes it hard to spot.

/Jens Axel

-- 
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.


[racket-users] Defining a symbol breaks symbols?

2015-09-30 Thread Lyle Kopnicky
Hi folks,

It seems that if I (incorrectly) quote a symbol in a 'define' form, it breaks 
all symbols from that point on. I would expect instead it would give me an 
error saying that I passed the wrong sort of thing to 'define', and not break 
future use of symbols. Is this a bug?

Welcome to DrRacket, version 6.2.1 [3m].
Language: racket; memory limit: 128 MB.
> 'foo
'foo
> 'bar
'bar
> (define 'foo 5)
> 'foo
. . foo: undefined;
 cannot reference an identifier before its definition
> 'bar
. . bar: undefined;
 cannot reference an identifier before its definition
> 

Thanks,
Lyle

-- 
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.


Fwd: [racket-users] Defining a symbol breaks symbols?

2015-09-30 Thread Lyle Kopnicky
-- Forwarded message --
From: *Lyle Kopnicky* <lylew...@gmail.com>
Date: Wednesday, September 30, 2015
Subject: [racket-users] Defining a symbol breaks symbols?
To: Jason Hemann <jhem...@umail.iu.edu>


Ha, thanks, Jens and Jason, for the explanation. That makes sense. I'm used
to static languages lately and it's been a long time since I've programmed
in a Lisp.

See question inline.

On Sep 30, 2015, at 10:43 AM, Jason Hemann <jhem...@umail.iu.edu
<javascript:_e(%7B%7D,'cvml','jhem...@umail.iu.edu');>> wrote:

I don't think that's a bug. Instad, it's fun with reader macros. 'x expands
into (quote x)

What you've got there is something like (define (quote foo) 5). And is a
perfectly good looking function.

And it's useable too.

> '`bar
5

This sort of thing can be fun and useful

> (define c3 (lambda (quote) (lambda (z) '''z)))
> ((c3 add1) 0)
3


That bothers me a bit. It looks unhygienic, as the quote function is being
captured. I guess reader macros can't have hygiene?

JBH

On Wed, Sep 30, 2015 at 1:35 PM, Lyle Kopnicky <lylew...@gmail.com
<javascript:_e(%7B%7D,'cvml','lylew...@gmail.com');>> wrote:

> Hi folks,
>
> It seems that if I (incorrectly) quote a symbol in a 'define' form, it
> breaks all symbols from that point on. I would expect instead it would give
> me an error saying that I passed the wrong sort of thing to 'define', and
> not break future use of symbols. Is this a bug?
>
> Welcome to DrRacket, version 6.2.1 [3m].
> Language: racket; memory limit: 128 MB.
> > 'foo
> 'foo
> > 'bar
> 'bar
> > (define 'foo 5)
> > 'foo
> . . foo: undefined;
>  cannot reference an identifier before its definition
> > 'bar
> . . bar: undefined;
>  cannot reference an identifier before its definition
> >
>
> Thanks,
> Lyle
>
> --
> 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
> <javascript:_e(%7B%7D,'cvml','racket-users%2bunsubscr...@googlegroups.com');>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-09-30 Thread Matthias Felleisen

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? 

Does "reading code" happen at run-time here? 
Is macro expansion a run-time activity? 
Types? See below for a typed version of your puzzle. 

Oh I know, "static" means good, just like "dynamic" means good :-) 

#lang typed/racket

(: quote (-> Any Any))
(define 'foo foo)

(quote 10)
(quote "any")

-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-09-30 Thread Alex Knauth

> On Sep 30, 2015, at 5:45 PM, Alex Knauth  wrote:
> 
> 
>> On Sep 30, 2015, at 4:19 PM, Lyle Kopnicky > > wrote:

>> That bothers me a bit. It looks unhygienic, as the quote function is being 
>> captured. I guess reader macros can't have hygiene?
> 
> It is an unhygienic reader macro, because it captures the quote from its use 
> instead of racket's quote.
> 
> It turns out reader macros can have hygiene, which I use for things like my 
> afl meta-language. Other languages like rackjure, curly-fn, and sugar/debug 
> also use hygiene in reader macros. 
> 
> I don't have time for a full explanation right now, but I'll come back in ~3 
> hours (after choir rehearsal) and give you one if your interested.
> 
> Alex Knauth

Ok. For hygienic macros to work, there has to be a scope where the macro is 
used, and a scope where the macro is defined.

You can define a current-syntax-introducer parameter in the main reader for the 
whole module, which you will call to introduce that scope on the entire module.

Then in the reader-macro procedure, you can refer to that parameter and use on 
the input and output.

-- 
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: [racket-users] Defining a symbol breaks symbols?

2015-09-30 Thread Alex Knauth

> On Sep 30, 2015, at 4:19 PM, Lyle Kopnicky <lylew...@gmail.com> wrote:
> 
> 
> 
> -- Forwarded message --
> From: Lyle Kopnicky <lylew...@gmail.com <mailto:lylew...@gmail.com>>
> Date: Wednesday, September 30, 2015
> Subject: [racket-users] Defining a symbol breaks symbols?
> To: Jason Hemann <jhem...@umail.iu.edu <mailto:jhem...@umail.iu.edu>>
> 
> 
> Ha, thanks, Jens and Jason, for the explanation. That makes sense. I'm used 
> to static languages lately and it's been a long time since I've programmed in 
> a Lisp.  
> 
> See question inline. 
> 
> On Sep 30, 2015, at 10:43 AM, Jason Hemann <jhem...@umail.iu.edu 
> <javascript:_e(%7B%7D,'cvml','jhem...@umail.iu.edu');>> wrote:

>> This sort of thing can be fun and useful
>> 
>> > (define c3 (lambda (quote) (lambda (z) '''z)))
>> > ((c3 add1) 0)
>> 3
>> 
> 
> That bothers me a bit. It looks unhygienic, as the quote function is being 
> captured. I guess reader macros can't have hygiene?

It is an unhygienic reader macro, because it captures the quote from its use 
instead of racket's quote.

It turns out reader macros can have hygiene, which I use for things like my afl 
meta-language. Other languages like rackjure, curly-fn, and sugar/debug also 
use hygiene in reader macros. 

I don't have time for a full explanation right now, but I'll come back in ~3 
hours (after choir rehearsal) and give you one if your interested.

Alex Knauth

-- 
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.