On 11/19/2016 11:45 PM, Alex Knauth wrote:
On Nov 19, 2016, at 1:51 PM, Dmitry Pavlov <[email protected]> wrote:
Out of curiosity, why do you want this?
I have a bunch of parameters (in the Racket sense of the word)
that are "read-only" throughout the module, i.e. there are no
modifications via calls (parameter value).
Most of parameters' values are themselves functions.
So what I wanted to save a couple of parentheses on
function calls: (parameter arg ...)
instead of ((parameter) arg ...)
Here's a question: do you want `parameter` to be a recond of the value of the
parameter at that time, or do you want it to be a function that, when called,
uses the current value then?
The former, I think.
For example if you say
(use-f parameter)
Where
(define (use-f f)
(do-something-that-could-affect-the-parameter)
(f arg ...))
Using one strategy this would still use the old value of the parameter, and
using the other it would use the new version after
(do-something-that-could-affect-the-parameter). Which do you want?
There are no modification of parameters, aside from a single (parameterize).
My parameters are "global", are not passed between functions, and are
(require)-d from another module.
There are other modules the parameters are (require)-d into.
I use parameters to avoid the pain of passing everything to every function on
the way.
(If there is another way to do that in Racket, I would be happy to know.)
My code is basically this
(require a-module-with-parameters)
(define (main)
(parameterize ((parameter1 (determine-value-for-parameter-1-basing-on-input))
(parameter2 (determine-value-for-parameter-2-basing-on-input))
...)
(subroutine-1)
(subroutine-2)
...
))
(define (subroutine-1)
(sub-subroutine-3))
(define (sub-subroutine-3)
(some-func (parameter-1 some-arg))
Without the macro, the last line would have been
(some-func ((parameter-1) some-arg)
Best regards,
Dmitry
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.