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] Re: slideshow with viewer input?

2015-10-18 Thread Jay McCarthy
The slide is basically a canvas%, so it can't contain radio-box%, etc.

So, the way to do this is to use the 'interactive' pict:

http://docs.racket-lang.org/slideshow/Primary_Slide_Functions.html?q=interactive#%28def._%28%28lib._slideshow%2Fbase..rkt%29._interactive%29%29

That creates another frame on the slideshow that is embedded in the
slide. You'd put in that frame% all the normal GUI stuff you want.

I've used this in the past to embed a movie into my title slide:

https://github.com/jeapostrophe/presentations/blob/master/201309-racketcon/lib.rkt#L36

Jay

On Sun, Oct 18, 2015 at 3:19 AM,   wrote:
> I partly answered my own question. it's entirely possible to have a pop-up, 
> e.g. using gui-utils:get-choice, within the flow of a slide presentation, and 
> have its result control the subsequent slide flow.
>
> I was thinking about having questions on the slide screen, with checkboxes or 
> radio buttons.
>
> On Saturday, October 17, 2015 at 11:53:12 PM UTC-7, Byron Davies wrote:
>> Is there an example anywhere of a slideshow presentation that takes 
>> non-trivial input from the viewer? In a tutorial, I’d like to have the 
>> viewer answer questions (e.g,, via menu or checkboxes) as a primitive check 
>> on understanding.
>
> --
> 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.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D&C 64:33

-- 
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] Re: slideshow with viewer input?

2015-10-18 Thread byrondavies
I partly answered my own question. it's entirely possible to have a pop-up, 
e.g. using gui-utils:get-choice, within the flow of a slide presentation, and 
have its result control the subsequent slide flow.

I was thinking about having questions on the slide screen, with checkboxes or 
radio buttons.

On Saturday, October 17, 2015 at 11:53:12 PM UTC-7, Byron Davies wrote:
> Is there an example anywhere of a slideshow presentation that takes 
> non-trivial input from the viewer? In a tutorial, I’d like to have the viewer 
> answer questions (e.g,, via menu or checkboxes) as a primitive check on 
> understanding.

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