
I have an _ that goes missing in the rendering - any ideas? The result:

@(defstruct flomat ([m natural?] [n natural?] [a _flomat] [lda natural?]))

The _
in a : _flomat
is missing.

Absent a binding, _
at the start of an identifier is treated as a request to typeset in italic. The solution may be a (require (for-label ...))
so that _flomat
is bound.

Thanks!

I kind of wanted something to check the existence of a module without actually loading it.

I have added a new section to the documentation of flomat
in order to describe the representation. Is it clear?
https://docs.racket-lang.org/manual-flomat/index.html?q=flomat#%28part._.Reference%29

Am I missing something? I can find _float
_double
and _longdouble
in the ffi - but I can’t find _complex
.

Yes - I am missing something - complex numbers in C aren’t handled the same way float, double and longdouble is. https://en.wikipedia.org/wiki/C_mathematical_functions#complex.h

And https://stackoverflow.com/questions/34103818/swift-blas-cblas-cgemv-complex-numbers answers the rest.

Haven’t they added _Complex
recently?

Yes. In ’99 but as a type modifier.

So you can have complex numbers where the real and imaginary parts are singles, doubles or longs.

you can check if the module name can be resolved.

Is there a correct way to clone a namespace? I am building some sort of with
operator in racket… so I need to eval
code in namespace which contains customized bindings, but as I can see there is no function to clone namespace. I have made my own: (define (namespace-copy! dest base)
(begin0 dest
(for ((key (in-list (namespace-mapped-symbols base))))
(let ((value (namespace-variable-value key #f void base)))
(when (not (void? value))
(namespace-set-variable-value! key value #f dest))))))
But here is a problem, it can not copy macro from source namespace(their (namespace-variable-value <key> #f void namespace
is just #<void>
), so this method is incomplete. I have found an old discussion which mentions this topic, but no solution was proposed https://groups.google.com/forum/#!msg/racket-users/rRC2rKBAr7c/KHKHq4yBBpcJ
So, is there a correct way to clone a namespace? Thank you :)

Example which illustrates the current namespace-copy!
implementation problem http://pasterack.org/pastes/23019

Probably this is a case where understanding what you want to accomplish is necessary to figure out the right way forward.

My goal is to call code in an environment where some of the bindings could be shadowed.
I want to derive a new namespace from (current-namespace)
where I could define any bindings I like(for example shadow some functions), then use it to eval some code and discard namespace after that.
For example: I may have a function which do some job (define (show x) (displayln x))
But I want to make it work in a different way when calling code wrapped into some macro, example: (show "test") ;; -> test
(with ((show (lambda (x)
(display "[info]: ")
(show x))))
(show "test")) ;; -> [info]: test
I think the correct solution here is eval
, and this is why namespaces
’ have come onto my mind. Just copy a namespace and shadow some symbols inside, what could go wrong? :)

What makes with
different from let
?

In my case body could be provided by user

I mean it’s an argument

How about taking that input, wrapping it in a let
form to establish the custom bindings, and the evaluating it (in an uncustomized namespace)?

and then*

Hmmm, thats an interesting point of view. And it is working: #lang racket
(require racket/syntax
(for-syntax racket/base
racket/syntax))
(define-syntax (with stx)
(syntax-case stx ()
((_ ((k v) ...) body ...)
(syntax (eval (quote (let ((k v) ...) body ...)))))))
(define-syntax (decorate stx)
(syntax-case stx ()
((_ v) (syntax (string-append "*" v "*")))))
(define (show x) (displayln x))
(define-namespace-anchor anchor)
(parameterize ((current-namespace (namespace-anchor->namespace anchor)))
(show (decorate "test"))
(with ((show (lambda (x) (display "[info]: ") (show x))))
(show (decorate "test"))))
Is this a part of motivation for not doing namespace-copy/clone? Ha-ha, just kidding. I really love this solution, thank you!

Hmm, you said you’re taking user input for the body of the with
, but that looks like it’s part of the code. Unless you’re actually inputting the code at run time, you can probably avoid eval
. I guess I’m not sure what you’re what you’re trying to do, but congrats on being unstuck.
(Personally, sometimes I’ve wanted to copy namespaces too. I don’t know the reasoning behind the current design.)

(In this case, it seems you can avoid eval
by just defining with
to do the same thing as let
: (define-syntax-rule (with args ...) (let args ...))
)

Yes, eval here is useless.
What could also be interesting is to make the scope completely dynamic, but in this case namespace manipulation is the only possible way I could think about