[racket-users] get the contract of a (or any) function - or find matching functions

2016-07-16 Thread mattapiroglu
Hi,

Thanks again and again for all the work on racket. Great language / 
implementation.

I wonder if there's a way to get the contract of functions in the libraries?

PS. I'm trying to find target functions in the namespace that'll 'match' the 
values I have (i.e. that can 'work with' the values I have). Any guidance on an 
easier or different approach are greatly welcome.

PPS. I use untyped :)

-- 
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: Re-using an identifier as a submodule name?

2016-07-14 Thread mattapiroglu
On Friday, July 15, 2016 at 2:22:50 PM UTC+10, Jack Firth wrote:
> I've got a macro that extends function definition by letting the user rebind 
> some identifiers with different values, which are then only available in a 
> certain context. For the sake of simplicity suppose it looks like this:
> 
> (define/foo (func v ...)
>   #:bind [helper1 expr]
>   #:bind [helper2 other-expr]
>   (helper1 v ...)
>   (helper2 v ...))
> 
> I would like helper1 and helper2 to have their normal meaning unless I'm 
> inside a special `with-foo` form like so:
> 
> (helper1 'a) ; normal behavior
> 
> (with-foo func
>   ; in here, helper1 and helper2 are bound to expr and other-expr instead
>   (helper1 'a))
> 
> I'd also like `with-foo` to be the only way to access the versions of helper1 
> and helper2 that have this alternate behavior. I'm attempting to do this with 
> some submodule hackery, essentially I'm expanding the above to this:
> 
> (define (func v ...)
>   (helper1 v ...)
>   (helper2 v ...))
> 
> (module foo racket/base
>   (module+ func
> (define helper1 expr)
> (define helper2 other-expr)
> (provide (all-defined-out
> 
> (begin
>   (require (submod ".." foo func))
>   (helper 1))
> 
> My reasoning is that by letting "func" double as a submodule identifier, I 
> can easily bring all the specially-bound identifiers associated with func 
> into scope, and by putting that submodule in a "foo" submodule I can hide the 
> existence of the foo submodule so only `with-foo` knows how to require the 
> correct "func" module. But I'm hitting scope issues - I'm not sure hot to 
> make the redefinitions of func available in (body ...) in a (with-foo func 
> body ...) use, naively adding the require imports fails to bring them into 
> scope. Various combinations of using syntax/loc and datum->syntax on the 
> require statement, the require submod path, and/or the body are all failing 
> to do what I want.
> 
> How can I achieve this? Is there a better way to try and do this?

Although I'm not experienced enough to understand all that's going on in your 
design, I wanted to remind you of (require (for-syntax )) since you're using 
the required module in the macro?

-- 
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] identifier-out-of-context when trying to make a debug-repl

2016-07-14 Thread mattapiroglu

> I've noticed that if it can refer to a module-level immutable variable, 
> `eval` seems to know that it's immutable. So is there any way to define a new 
> variable as immutable in a namespace?
> 

I believe box-immutable isn't what you're looking for, or would be too obvious 
an answer?

(eval '(define y (box-immutable 1)) ns)

-- 
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] (namespace-variable-value) not working with a struct definition?

2016-07-09 Thread mattapiroglu
On Saturday, June 25, 2016 at 8:13:04 AM UTC+10, Matthew Flatt wrote:

> 
> For what it's worth, I recommend avoiding `namespace-variable-value`.
> There's usually a better way, but it depends on what you're trying to
> do.
> 

Thanks much for the lead, I am now using eval with relevant custom namespaces.

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