
(eq? (expt 2 3) (expt 2 3)) => #t (eq? (expt 2 100) (expt 2 100)) => #f why?

eq?
tests physical equality

use =
to test numerical equality

Is there an equal-hash-code/recur
similar to equal?/recur
?

@jsn short answer: (expt 2 3)
is a fixnum, no objects are allocated. (expt 2 100)
is not a fixnum.

@jsn Test with fixnum?

Added.
Instead of adding 4 functions, I could have added just 1 that’s something like syntax-binding-set-extend
to make a single binding and then have datum->syntax
accept a list of bindings as its first argument. I decided to go through an intermediate syntax-binding-set
data structure, instead, because it seems more adpatible to different internal representations, and I decided to keep it separate from datum->syntax
.

I would try to make a timeline renderer using the rectangles
renderer

Thanks for the explanation about object allocation and fixnums

Is it possible to turn off string normalization in xrepl
?

Everytime I wanted to paste a lambda function it became hex digits (like (λ (x) x)
became (\U+FFCE\U+FFBB (x) x)
)

@pocmatos You may want to look at web-server/lang/serial-lambda
, which gives you serial-lambda
, a version of lambda
that works with serialize
and deserailize
.

Wootz, thanks. :smile:

@jsn Check eq? eqv? and equal? in the docs.

Leif and I just tried to use include/reader
in a scribble file using Scribble’s read-syntax-inside
reader: https://gist.github.com/bennn/9901db528a7ac3fd8247c1fad55ab2d6

the include seems to run forever, but along the way it throws a contract error from cadar

is this a bug?

To be clear, cadar
isn’t the bug, but whoever passed the argument to cadar
:
racket verbim.rkt
verbim.rkt:9:11: include/reader: read error (cdadr: contract violation
expected: (cons/c any/c (cons/c pair? any/c))
given: '((0 . 0) #f))
in: (include/reader "text.rkt" scb:read-syntax-inside)
location...:
verbim.rkt:9:11

@shu—hung You are probably using a build of libedit that doesn’t support Unicode. Try installing the readline library and the readline-gpl
package.

@mflatt and @jbclements About a week ago I sent you both a message wondering why Racket’s rsound and portaudio packages weren’t working in a VM.

Namely, I was getting an ffi error, stating it couldn’t find the portaudio dll.

(I didn’t have this problem on physical machines oddly enough.)

@mflatt thank!! let me try that

Anyway, while I still am not sure what the problem was, I put together a machine set up with the problem:


I would be interested in finding out why I would get that problem anyway. :slightly_smiling_face:

Could anyone explain the motivation for local-expand
and related APIs accepting a list of definition contexts, rather than just one? I can see why one would want to create a definition context extending an existing one with syntax-local-make-definition-context, but given that I don’t see the need to pass a list of them to local-expand
. Do these two somehow differ in behavior?

@michael.ballantyne They do. Providing a definition context to local-expand
adds brings all the bindings of the immediate contexts and their transitive parents into scope, but it only adds the scopes of the immediate contexts.

Hmm. When might I want to have a context as a parent, but not add its scope?

I believe that’s generally the behavior you want… I think it’s rare that you actually want to add the scope of parent binding forms. Imagine you have nested definitions contexts that ostensibly represent a binding structure like (let (....) (let (....) e))
. When the outer let
expands, it should add its scope to its body, but when the inner let
expands, the scope of the outer let
should already be on the body, so it shouldn’t add any additional scopes.

I don’t think it’s likely to matter very much in practice, but it could matter if you use first-class definitions contexts in strange ways.

(I found this behavior confusing, and I didn’t understand it until recently, so I made an effort to improve the documentation for v7. It could definitely be improved further, though.)

I thought I was meant to think about definition context scopes as “inside-edge” scopes that should end up on all syntax that ends up within a scope (such as within the nested let), not just on syntax that originated in the scope.

Whereas I’d use outside-edge” scopes from make-syntax-introducer to create the scopes for the two let
forms that might distinguish identifiers that originated within them vs were introduced into them by a macro.

Yes, I think your understanding is correct, but the inside edge scope is still only added by the outer let
. After the body is expanded, the scope is added, but the inner let
has no reason to do anything with the outer let
’s inside-edge scope.

Have you used multiple immediate contexts for something before?

That one hasn’t come up for me yet.

I believe I have, but I don’t remember what it was…

In any case, I’m not sure how clear the “right” behavior is, since the difference only really comes up in complex uses of local-expand
and first-class definition contexts, which are (1) rare and (2) probably already built with the current model in mind.

So I’m lost as to what this would mean in the usual, intuitive interpretation of hygiene.

Yeah… right now I’m trying to figure out how to get use-site scopes to work properly when making a custom expander with only local-apply-transformer.

This is only tangentially relevant, but the docs for local-apply-transformer
have been wrong since I wrote them, and I am not sure how to rephrase them. :disappointed:

Oh? What’s been wrong?

The documentation claims that “The result is similar to expanding (m stx)
with local-expand
, where m
is bound to transformer
,” except that isn’t right, since transformer
is applied to stx
directly, not wrapped in any additional syntax.

Oh! Right.

I can’t figure out how to draw a clear analogy to local-expand
without bringing in the awkward dance involving quote
, which is too close to the implementation, so maybe the line should just be cut.

I sort of like the analogy, though, since I think thinking about local-apply-transformer
as “local-expand-once
but the transformer is explicitly supplied” is probably more useful to most people than “(transformer stx)
but with proper handling of macro-introduction scopes”. In any case, having both explanations is convenient.

@dthien has joined the channel

Hello, I’m trying to make a new racket package, but I can’t figure out how to make it do non-racket things when it installs. Specifically, I want to compile a C library from a github repo which creates a shared object and then install the shared object. The racket file is just the ffi bindings.

Any guidance is appreciated :smiley:

The simplest would be to include the binary.

+1 to shipping the binary. If you must build from source, however, you can take a look at what the bcrypt
package does, which builds bcrypt
from source on installation. https://github.com/samth/bcrypt.rkt

Ok, thanks for the info!

It’s possible to ship binaries for more than one platform.

I saw there was the copy-foreign-libs
option for the info.rkt
file, is there another option in there for shipping different binaries for different platforms?

you can use install-platform
to control which platform that collection should be used for

Awesome, thanks for the help!

For example, if you have a package foo
, you could have two subdirectories foo/native/x86_64-macosx/
and foo/native/x86_64-linux-natipkg/
, each with their own info.rkt
file that includes both copy-foreign-libs
and install-platform
.

(The directory names aren’t meaningful; they can be anything. What matters is what’s in install-platform
.)

Cool ty!

@lexi.lambda Do you know of an example. I am looking at portaudio, but I don’t think copy-foreign-libs is used. https://github.com/jbclements/portaudio

I have an example in one of my own projects, but it’s a private repo, and I don’t want to make it public right now… and unfortunately I don’t know of any other examples.