Re: [racket-users] parameterize working across dynamic-require and phase change

2016-12-07 Thread Robby Findler
Or another hack: put the parameter's value in teh filesystem and use
parameter guards to fish it out of there.

This would be useful only if you consider it temporary tho. :)

Robby


On Wed, Dec 7, 2016 at 2:09 PM, Matthew Flatt  wrote:
> At Wed, 7 Dec 2016 12:01:24 -0800 (PST), Dan Liebgold wrote:
>> On Tuesday, December 6, 2016 at 5:00:47 PM UTC-8, Robby Findler wrote:
>> >
>> > Perhaps there is another way to achieve the effect you want in a way
>> > that is more friendly to creating .zo files?
>> >
>>
>> Yes, this is the crux of the issue. In my case I have a system that deals 
>> with
>> modules that may or may not have .zo files. I'm try to parameterize something
>> at compile time for generating the .zo and also at dynamic-require time (when
>> the required module may or may not have the corresponding .zo file).
>>
>> The best solution would be to simplify the compile-time logic such that the
>> parameterization isn't required...  until then I may have to fix the system 
>> to
>> parameterize the phases separately.
>
> As a last resort, you might be able to use
> `dynamic-require-for-syntax`, which will let you grab a phase-1 value
> (such as a parameter) for use in phase-0 code.
>
> The `dynamic-require-for-syntax` function is a bad idea, but maybe it's
> useful in the short run.
>
> --
> 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] parameterize working across dynamic-require and phase change

2016-12-07 Thread Matthew Flatt
At Wed, 7 Dec 2016 12:01:24 -0800 (PST), Dan Liebgold wrote:
> On Tuesday, December 6, 2016 at 5:00:47 PM UTC-8, Robby Findler wrote:
> > 
> > Perhaps there is another way to achieve the effect you want in a way
> > that is more friendly to creating .zo files?
> > 
> 
> Yes, this is the crux of the issue. In my case I have a system that deals 
> with 
> modules that may or may not have .zo files. I'm try to parameterize something 
> at compile time for generating the .zo and also at dynamic-require time (when 
> the required module may or may not have the corresponding .zo file).
> 
> The best solution would be to simplify the compile-time logic such that the 
> parameterization isn't required...  until then I may have to fix the system 
> to 
> parameterize the phases separately.

As a last resort, you might be able to use
`dynamic-require-for-syntax`, which will let you grab a phase-1 value
(such as a parameter) for use in phase-0 code.

The `dynamic-require-for-syntax` function is a bad idea, but maybe it's
useful in the short run.

-- 
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] parameterize working across dynamic-require and phase change

2016-12-07 Thread Dan Liebgold
On Tuesday, December 6, 2016 at 5:00:47 PM UTC-8, Robby Findler wrote:
> 
> Perhaps there is another way to achieve the effect you want in a way
> that is more friendly to creating .zo files?
> 

Yes, this is the crux of the issue. In my case I have a system that deals with 
modules that may or may not have .zo files. I'm try to parameterize something 
at compile time for generating the .zo and also at dynamic-require time (when 
the required module may or may not have the corresponding .zo file).

The best solution would be to simplify the compile-time logic such that the 
parameterization isn't required...  until then I may have to fix the system to 
parameterize the phases separately.

-- 
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] Why are hash and make-hash not symmetric?

2016-12-07 Thread David Storrs
Thank you, Spencer and Matthew both.  That gives me enough to go on with.


On Wed, Dec 7, 2016 at 9:59 AM, Matthew Flatt  wrote:

> Maybe there's some technical reason that I've forgotten, but I think
> it's just that `hash` is newer and was an experiment toward a better
> interface. A `mutable-hash` function would make sense, as far as I can
> tell.
>
> Meanwhile, something like `(hash-copy (hash 'a 1 'b 2))` might be the
> most convenient option right now.
>
> At Wed, 7 Dec 2016 08:49:42 -0800, David Storrs wrote:
> > -> (hash 'a 1 'b 2)
> > '#hash((a . 1) (b . 2))
> >
> > -> (make-hash '((a . 1) (b . 2)))
> > '#hash((b . 2) (a . 1))
> >
> > -> (make-hash 'a 1 'b 2)
> > (make-hash 'a 1 'b 2)
> > ; make-hash: arity mismatch;
> > ;  the expected number of arguments does not match the given number
> > ;   expected: 0 to 1
> > ;   given: 4
> > ; [,bt for context]
> >
> > Why does 'make-hash' not work like 'hash'?  Is it possible that a flag
> > could be added that would *make* it work like hash?  Or, alternatively,
> > does another function exist that will create a mutable hash but will
> accept
> > N arguments the way 'hash' does?  I understand that it's not very FP to
> use
> > mutation but there are certain problems that are easier that way.
>
>

-- 
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] Why are hash and make-hash not symmetric?

2016-12-07 Thread Matthew Flatt
Maybe there's some technical reason that I've forgotten, but I think
it's just that `hash` is newer and was an experiment toward a better
interface. A `mutable-hash` function would make sense, as far as I can
tell.

Meanwhile, something like `(hash-copy (hash 'a 1 'b 2))` might be the
most convenient option right now.

At Wed, 7 Dec 2016 08:49:42 -0800, David Storrs wrote:
> -> (hash 'a 1 'b 2)
> '#hash((a . 1) (b . 2))
> 
> -> (make-hash '((a . 1) (b . 2)))
> '#hash((b . 2) (a . 1))
> 
> -> (make-hash 'a 1 'b 2)
> (make-hash 'a 1 'b 2)
> ; make-hash: arity mismatch;
> ;  the expected number of arguments does not match the given number
> ;   expected: 0 to 1
> ;   given: 4
> ; [,bt for context]
> 
> Why does 'make-hash' not work like 'hash'?  Is it possible that a flag
> could be added that would *make* it work like hash?  Or, alternatively,
> does another function exist that will create a mutable hash but will accept
> N arguments the way 'hash' does?  I understand that it's not very FP to use
> mutation but there are certain problems that are easier that way.

-- 
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] Why are hash and make-hash not symmetric?

2016-12-07 Thread Spencer Florence
For symmetry there is "make-immutable-hash", which is like "hash" but has
the interface of "make-hash". (I don't know why "hash" is the way it is
though).

--spencer

On Wed, Dec 7, 2016 at 10:49 AM David Storrs  wrote:

> -> (hash 'a 1 'b 2)
> '#hash((a . 1) (b . 2))
>
> -> (make-hash '((a . 1) (b . 2)))
> '#hash((b . 2) (a . 1))
>
> -> (make-hash 'a 1 'b 2)
> (make-hash 'a 1 'b 2)
> ; make-hash: arity mismatch;
> ;  the expected number of arguments does not match the given number
> ;   expected: 0 to 1
> ;   given: 4
> ; [,bt for context]
>
> Why does 'make-hash' not work like 'hash'?  Is it possible that a flag
> could be added that would *make* it work like hash?  Or, alternatively,
> does another function exist that will create a mutable hash but will accept
> N arguments the way 'hash' does?  I understand that it's not very FP to use
> mutation but there are certain problems that are easier that way.
>
> --
> 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.


[racket-users] Why are hash and make-hash not symmetric?

2016-12-07 Thread David Storrs
-> (hash 'a 1 'b 2)
'#hash((a . 1) (b . 2))

-> (make-hash '((a . 1) (b . 2)))
'#hash((b . 2) (a . 1))

-> (make-hash 'a 1 'b 2)
(make-hash 'a 1 'b 2)
; make-hash: arity mismatch;
;  the expected number of arguments does not match the given number
;   expected: 0 to 1
;   given: 4
; [,bt for context]

Why does 'make-hash' not work like 'hash'?  Is it possible that a flag
could be added that would *make* it work like hash?  Or, alternatively,
does another function exist that will create a mutable hash but will accept
N arguments the way 'hash' does?  I understand that it's not very FP to use
mutation but there are certain problems that are easier that way.

-- 
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] parameterize working across dynamic-require and phase change

2016-12-07 Thread Matthias Felleisen

My initial reaction would be to explicitly split “module.rkt” into two pieces: 
 — its compile-time code especially an exported parameter a
 — its run-time code, which uses the same parameter 
Your client module could then require each piece at the correct phase. 

This also ought to work with the .zo files. 

I think. Perhaps. — Matthias







> On Dec 6, 2016, at 8:00 PM, Robby Findler  wrote:
> 
> My initial reaction is that that's a bad idea because it means that
> you're not cooperating separate compilation when you do things like
> that. That is, if module.rkt's compilation were affected by the
> parameter `a`, then if there were a .zo file (because someone did
> 'raco setup' or 'raco make' or the like on module.rkt), then you'd get
> one version of the code, and if there weren't, then you'd get a
> different version of the code.
> 
> Perhaps there is another way to achieve the effect you want in a way
> that is more friendly to creating .zo files?
> 
> Robby
> 
> 
> On Tue, Dec 6, 2016 at 6:28 PM, Dan Liebgold
>  wrote:
>> 
>> Hi -
>> 
>> I've asked this question privately of Matthew Flatt, but I'll throw it out 
>> to the group in case anyone else wants a crack at it.
>> 
>> If I do this:
>> 
>> (parameterize ([a 3])
>>  (dynamic-require "module.rkt" 'func)
>>  (func))
>> 
>> 
>> ...where the current module and "module.rkt" both require in parameter "a", 
>> and func uses the value "a" during the syntax phase -- (a) will not be 3... 
>> it will be the value bound during parameter creation.
>> 
>> Is there a way to parameterize a in this case?
>> 
>> Thanks,
>> Dan
>> 
>> --
>> 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.

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