plragde
2019-8-1 13:04:43

@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


ben
2019-8-1 15:18:46

here’s a patch that can remove contracts from a clone of the racket repo: https://github.com/bennn/racket-minus-contracts


jab
2019-8-1 15:29:57

I wasn’t, thank you, look forward to reading!


soegaard2
2019-8-1 17:35:56

@pocmatos Writes that he uses the following to disable his own contracts: https://gist.github.com/pmatos/c8e3e667d2e4accf3c85f745a460e3f2



soegaard2
2019-8-1 20:00:46

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?

https://docs.racket-lang.org/metapict/index.html?q=brushstipple#%28def._%28%28lib._metapict%2Fpict..rkt%29._brushstipple%29%29


ben
2019-8-1 20:03:04

Scribble probably isn’t running in that folder. Can you add ++extra "texture.jpg" to the command-line flags?


soegaard2
2019-8-1 20:04:52

I can try, but what do I do about the build server?


ben
2019-8-1 20:09:15

I’m not sure, but there must be examples of this in the racket or htdp docs


soegaard2
2019-8-1 20:09:19

Yes - that works, when I run scribble from another folder.


soegaard2
2019-8-1 20:11:13

I’ll see if a runtime-path fixes the problem.


soegaard2
2019-8-1 20:28:11

soegaard2
2019-8-1 20:28:57

The offending (bitmap "texture.jpeg") is inside an interaction, so it is not straightforwards how to use a runtime-path.


notjack
2019-8-1 21:09:42

Whoa, this is awesome and very relevant to me


notjack
2019-8-1 21:11:20

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)


notjack
2019-8-1 21:11:43

(doesn’t allow subtyping or mutable fields, but does allow structure type properties)


soegaard2
2019-8-1 21:12:35

There is a lot going on in the general case of structs.


notjack
2019-8-1 21:13:11

Agreed. I actually made a couple of different macros to simplify them for different use cases


notjack
2019-8-1 21:14:30
> (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))
42

soegaard2
2019-8-1 21:14:36

This is my way of representing structs in JavaScript: https://github.com/soegaard/urlang/blob/master/compiler-rjs/runtime.rkt#L1727


notjack
2019-8-1 21:15:07

Oh that’s neat


notjack
2019-8-1 21:15:10

I like that


soegaard2
2019-8-1 21:17:06

make-struct-type was pretty complicated.


notjack
2019-8-1 21:21:38

Yes


notjack
2019-8-1 21:21:46

That’s a function that’s in desperate need of keyword arguments


soegaard2
2019-8-1 21:21:57

:slightly_smiling_face:


notjack
2019-8-1 21:23:00

For my macros, I also made dynamic interfaces to them. There’s tuple / record / wrapper equivalents to make-struct-type.


soegaard2
2019-8-1 21:23:22

So dot-notation will work?


notjack
2019-8-1 21:27:24

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

notjack
2019-8-1 21:28:46

Haven’t yet added static information though, so you can’t yet make match expanders for them.


soegaard2
2019-8-1 21:29:54

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.


notjack
2019-8-1 21:30:04

But I’d do that by adding something like a (tuple-binding [type tuple-type?] [descriptor-stx syntax?]) kind of thing.


notjack
2019-8-1 21:30:19

Ah, actually - whether or not field names are present at runtime depends on which kind of type you pick


notjack
2019-8-1 21:30:43

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)


soegaard2
2019-8-1 21:32:52

Wrapper types?


notjack
2019-8-1 21:33:04

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.


notjack
2019-8-1 21:33:22

Wrapper type = tuple type with exactly one field, a.k.a. a haskell newtype


soegaard2
2019-8-1 21:33:32

I see.


notjack
2019-8-1 21:34:18

Makes it easier when reading a module’s type definitions to tell what the general shape of them is at a glance


soegaard2
2019-8-1 21:34:49

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.


notjack
2019-8-1 21:36:57

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)


notjack
2019-8-1 21:37:45

does not work if the expression could result in multiple possible kinds of struct types though


soegaard2
2019-8-1 21:38:08

Yeah, if you help it can be made to work. (let ([A some-expression]) (declare A fish) A.color))


notjack
2019-8-1 21:40:34

it sort of does that but like in the define header


notjack
2019-8-1 21:40:57
(define ([A fish])
  A.color)

…or something like that


notjack
2019-8-1 21:41:07

remix is not well documented


notjack
2019-8-1 21:41:27

pretty much the only explanation of how it works is in Jay’s RacketCon talk about it



soegaard2
2019-8-1 21:42:35

Thanks.


notjack
2019-8-1 21:56:22

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


notjack
2019-8-1 21:57:36

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)


notjack
2019-8-1 21:58:44

Honestly I find it simplest to just completely ban all relative uses of require and instead always reference modules by their collection paths


notjack
2019-8-1 21:59:44

(the exception being requiring submodules)


soegaard2
2019-8-1 22:01:24

Worth a try.


soegaard2
2019-8-1 22:06:49

Using absolute paths is a pain, when you move files into a subfolder.


notjack
2019-8-1 23:27:19

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.


jesse
2019-8-2 04:30:24

[shameless plug] y’all are going to Racketfest, right? It’s just a couple weeks away! https://racketfest.com


jarcane
2019-8-2 06:36:18

@jarcane has joined the channel