@jab Are you aware of the original critique of SICP by the original Racket development team? https://www2.ccs.neu.edu/racket/pubs/jfp2004-fffk.pdf
here’s a patch that can remove contracts from a clone of the racket repo: https://github.com/bennn/racket-minus-contracts
I wasn’t, thank you, look forward to reading!
@pocmatos Writes that he uses the following to disable his own contracts: https://gist.github.com/pmatos/c8e3e667d2e4accf3c85f745a460e3f2
Totally missed this one: https://soft-dev.org/pubs/pdf/bolz_hirschfeld_kirilichev_pape__record_data_structures_in_racket.pdf
I have an example in a scribble document that contains (bitmap "texture.jpeg"). The image “texture.jpeg” is in the same folder as the scribble document. If I run (bitmap "texture.jpeg") in the repl, I see the image. However in the docs I see a “bitmap failed” bitmap instead. Any ideas for a fix?
Scribble probably isn’t running in that folder. Can you add ++extra "texture.jpg" to the command-line flags?
I can try, but what do I do about the build server?
I’m not sure, but there must be examples of this in the racket or htdp docs
Yes - that works, when I run scribble from another folder.
I’ll see if a runtime-path fixes the problem.
I think I can’t see the forrest for trees: https://github.com/soegaard/metapict/blob/master/metapict/scribblings/pict.scrbl#L165
The offending (bitmap "texture.jpeg") is inside an interaction, so it is not straightforwards how to use a runtime-path.
Whoa, this is awesome and very relevant to me
I made a define-record-type macro to simplify structs a little: > (define-record-type person (name age favorite-color))
> (person
#:name "Foobius"
#:age 214
#:favorite-color 'crimson)
(person
#:name "Foobius"
#:age 214
#:favorite-color 'crimson)
(doesn’t allow subtyping or mutable fields, but does allow structure type properties)
There is a lot going on in the general case of structs.
Agreed. I actually made a couple of different macros to simplify them for different use cases
> (define-tuple-type point (x y))
> (point 4 7)
(point 4 7)
> (define-wrapper-type seconds) ;; only one field, implicitly named "value"
> (seconds 42)
(seconds 42)
> (seconds-value (seconds 42))
42This is my way of representing structs in JavaScript: https://github.com/soegaard/urlang/blob/master/compiler-rjs/runtime.rkt#L1727
Oh that’s neat
I like that
make-struct-type was pretty complicated.
Yes
That’s a function that’s in desperate need of keyword arguments
:slightly_smiling_face:
For my macros, I also made dynamic interfaces to them. There’s tuple / record / wrapper equivalents to make-struct-type.
So dot-notation will work?
Dunno, I don’t know how dot-notation works in racket. What I mean is that for each kind of type, I made the following:
- An immutable, serializable, value describing the shape of the type. Example:
(tuple-type #:name 'point #:size 2). - An object that has an actual implementation of a type, which I called a descriptor. Example:
(make-tuple-implementation (tuple-type ...))returns atuple-descriptor?object. The descriptor provides the predicate, constructor, and accessor functions. - A macro that provides a convenient syntax for constructing a type and making a descriptor that implements it.
Haven’t yet added static information though, so you can’t yet make match expanders for them.
Well, that’s just it. Dot-notation is missing in racket, because information about field names is missing at runtime. So given your structures, there is enough information to implement dot-notation.
But I’d do that by adding something like a (tuple-binding [type tuple-type?] [descriptor-stx syntax?]) kind of thing.
Ah, actually - whether or not field names are present at runtime depends on which kind of type you pick
Record types: yes, there’s field names, represented by keywords. Tuple and wrapper types: no, there’s only a size (and there’s nothing for wrapper types since they always have size 1)
Wrapper types?
The compile-time tuple-binding thing would probably have field names in the form of identifiers, so if the dot-notation was resolved statically you could do it on tuples.
Wrapper type = tuple type with exactly one field, a.k.a. a haskell newtype
I see.
Makes it easier when reading a module’s type definitions to tell what the general shape of them is at a glance
In something like (let ([A some-expression]) A.a-field) there is no way to know what kind of struct A is at compile time. Some runtime information is needed.
Jay’s Remix language can know that at compile time by doing clever things to make let / define / etc. propagate an expression’s static information (for structure access the compile-time accessor info is called a “dot transformer”, so look for that term in the docs / code / readme)
does not work if the expression could result in multiple possible kinds of struct types though
Yeah, if you help it can be made to work. (let ([A some-expression])
(declare A fish)
A.color))
it sort of does that but like in the define header
(define ([A fish])
A.color)…or something like that
remix is not well documented
pretty much the only explanation of how it works is in Jay’s RacketCon talk about it
Thanks.
@soegaard2 Try making a module in your collection like mylibrary/example that has the define-runtime-path definition for the file and provides it, then in the scribble examples require mylibrary/example.
The example code is run inside an anonymous module dynamically with eval, so the only way it should refer to other modules or files is through require with absolute module paths (such as library paths to modules in collections)
Honestly I find it simplest to just completely ban all relative uses of require and instead always reference modules by their collection paths
(the exception being requiring submodules)
Worth a try.
Using absolute paths is a pain, when you move files into a subfolder.
It can still be a pain with relative paths when the files you don’t move refer to the files you do move. With absolute paths everywhere I find it much easier to automate the move because I can do a global search and replace.
[shameless plug] y’all are going to Racketfest, right? It’s just a couple weeks away! https://racketfest.com
@jarcane has joined the channel