leafac
2017-10-2 15:02:25

Today, I learned that:

> (equal? 'Π ; \Pi
          '∏ ; \prod
          )
#f
> (equal? 'Σ ; \Sigma
          '∑ ; \sum
          )
#f

leafac
2017-10-2 15:05:02

Moreover, when searching-and-replacing Σ → ∑ in DrRacket, it’s smart enough to match σ (lowercase Σ) as well :slightly_smiling_face:


ben
2017-10-2 16:42:12

leafac
2017-10-2 16:46:38

:fearful:


haffnersam
2017-10-2 17:10:05

@haffnersam has joined the channel


zenspider
2017-10-2 19:57:29

At racket summer school I was asking about racket hashlangs vs nanopass and Matt or Sriram (I don’t remember at this point, but I think it was the latter) advocated for racket hashlangs in the style of nanopass. There are pros and cons to both. With hashlangs, you lose the ability to insert/arrange/remove layers as easily as nonopass… But I’m not getting something about this approach. I spent an inordinate amount of time figuring out how to instantiate a module in order to implement run-with-lang for beautiful racket (so you can run via ./basic blahblah.bas)… it is clearly not meant to be an easy thing…


zenspider
2017-10-2 19:59:24

so… if I were to implement MANY racket hashlangs for a nanopass style architecture… how do a go from layer1 to layer2, etc?? I want to have completely separate passes for desugaring, ANF transformation, etc etc. (and at some point, I’d LOVE to disconnect entirely from racket as a backend and produce machine or VM code)… am I thinking about this wrong?


zenspider
2017-10-2 20:00:29

(the more I type this, the more I suspect I’m thinking top-down and should be thinking bottom up… but I’m (possibly) even more confused by that approach. Designing languages starts with the language, not the bottom layer mechanics)


leafac
2017-10-2 20:02:18

I guess part of the pitch of the Racket approach, as opposed to the Nanopass one, is that you don’t have to disconnect from Racket to generate VM code, because the Racket compiler is doing that for you.


zenspider
2017-10-2 20:03:41

absolutely. you get a TON for free… and I want that, for sure… ignore my parenthetical about eventually disconnecting from racket as a backend for now.


zenspider
2017-10-2 20:03:50

that’s a success problem. :slightly_smiling_face:


zenspider
2017-10-2 20:04:51

(I love questions like “what if we get too much traffic for heroku??” to which I answer “congratulations?“… but I’m not concerned with finishing, I’m concerned with starting)


leafac
2017-10-2 20:05:08

In my experience, the Nanopass approach is more appropriate than the Racket approach when I’m building a transpiler. In that case, I’m not targeting a machine, so linguistic reuse doesn’t apply. For example, I built CSS-expressions (https://docs.racket-lang.org/css-expr/index.html) using Nanopass, and I don’t see how I could’ve used the Racket way. (Though, from having talked to Jay, I believe it’s possible, it’s just beyond my reach.)


zenspider
2017-10-2 20:06:35

oh god… the domain in that doco… that’s amazing


leafac
2017-10-2 20:08:25

My other point is, unless you want to directly write code for the languages in every pass on the compiler, then it’s not worth having ‘#lang’s for them. Let them just be a collection of macros expanding to other macros. Or, at most, module languages, as opposed to full ‘#lang’s with custom readers.


leafac
2017-10-2 20:08:43

notjack
2017-10-2 20:09:24

@zenspider another idea is for hashlangs to provide more extension points that transform things that seem like they would require another language layer into things that hook into provided extension points and thus compose with other extensions


zenspider
2017-10-2 20:09:41

@leafac yes… and I’m learning actual CSS from it. :stuck_out_tongue:


zenspider
2017-10-2 20:10:09

@notjack ummm… I’m not following that


zenspider
2017-10-2 20:10:39

is that basically the same as @leafac’s comment?


notjack
2017-10-2 20:13:02

@zenspider things like #%app and #%datum can let you override parts of #lang racket by importing modules instead of changing the language’s reader. I think racket langs should move towards doing more of that


notjack
2017-10-2 20:16:16

I’d really like a way for requiring a module to somehow wrap all forms after the require statement in a macro defined by the required module


zenspider
2017-10-2 20:21:08

that’d be interesting but possibly scary. :slightly_smiling_face:


notjack
2017-10-2 20:21:45

absolutely :) but if langs don’t provide it, people do it anyway with metalanguages that operate by chaining readers together and that’s way easier to get wrong


zenspider
2017-10-2 20:23:40

I think I’d want it to be opt-in tho… like (require (inject-in somerequire form1 form2))


notjack
2017-10-2 20:24:49

that’s a good idea, and means it might be possible to implement it as a regular require transformer instead of a wrapper on top of require


notjack
2017-10-2 20:25:26

I like a name like module-body-in better tho :p inject-in makes me think it’s for some dependency injection framework


notjack
2017-10-2 20:27:13

I’d want to combine this with making #%app / #%datum / etc syntax parameters instead of magic identifiers inserted by the reader, that way a module-body-in form could override #%app by wrapping the module body in a syntax-parameterize form


cfinegan
2017-10-2 21:56:33

How can one create syntax for a keyword argument? I want to do something like #'(lamdba (a #:b c) ...) Where #:b c is generated from some identifiers in a macro.


samth
2017-10-2 21:58:40

@cfinegan you might be interested in #,@ or using ...


notjack
2017-10-2 21:59:10

@cfinegan (with-syntax ([foo-kw (make-keyword-dynamically ...)]) #'(lambda (a foo-kw c) ...) ought to work


notjack
2017-10-2 21:59:29

maybe


notjack
2017-10-2 22:00:18

see this part of the docs for with-syntax in particular:

> However, if any individual stx-expr produces a non-syntax object, then it is converted to one using datum->syntax and the lexical context and source location of the individual stx-expr.


zenspider
2017-10-2 22:01:09

the basics > (define val 'z) > (define key '#:y) > #`(lambda (x #,key #,val) 42) #<syntax:12:2 (lambda (x #:y z) 42)>


notjack
2017-10-2 22:01:38

^ and that example is using quasisyntax and unsyntax, and unsyntax performs the same conversion that with-syntax does


cfinegan
2017-10-2 22:06:22

But what if the y part of #:y is something I want to be generated from an identifier? Can I unquote just the part that is the name?


notjack
2017-10-2 22:07:15

@cfinegan You can use string->keyword to produce a keyword dynamically from a string


cfinegan
2017-10-2 22:07:33

awesome that sounds like exactly what I need, i’ll look into it. Thanks!


notjack
2017-10-2 22:07:47

:+1:


notjack
2017-10-2 22:39:49

does it still count as 3d syntax if a syntax object contains a non-prefab struct but that struct has an implementation of gen:custom-write?


lexi.lambda
2017-10-2 22:41:04

yes


notjack
2017-10-2 22:41:23

why?


lexi.lambda
2017-10-2 22:41:51

custom-write converts things to strings. perhaps the better question should be asking about serializable structs?


lexi.lambda
2017-10-2 22:42:57

more pointedly, custom-write does not have any notion of reading the result. 3D syntax is about things that aren’t roundtrippable.


notjack
2017-10-2 22:43:26

No, I mean custom write specifically. The case I’m thinking of is where a module is read with a reader that produces syntax objects containing structs to represent certain special kinds of syntactic constructs (as opposed to using tagged s-exps), and those structs implement custom write in such a way that the read-write contract holds but only if the custom reader is used


notjack
2017-10-2 22:43:53

so it would round-trip as long as the extended reader was used


lexi.lambda
2017-10-2 22:44:11

the notion of the reader is long gone by the time syntax objects are marshalled to bytecode


lexi.lambda
2017-10-2 22:45:13

that would mean bytecode loading would need to call a reader, which is a string parser


lexi.lambda
2017-10-2 22:45:17

that sounds like a very bad idea to me


notjack
2017-10-2 22:47:39

fully expanded syntax objects are the only syntax objects that are marshalled to bytecode correct? this use of syntax objects wouldn’t persist that far


lexi.lambda
2017-10-2 22:48:21

I don’t really understand what you’re asking. 3D syntax is only a problem when syntax objects are marshalled to bytecode; that’s the whole reason the notion of 2D/3D syntax exists, IIUC.


lexi.lambda
2017-10-2 22:49:06

If your syntax isn’t getting marshalled to bytecode, you can put whatever values you want in your syntax.


notjack
2017-10-2 22:55:24

The way this relates to marshalling is if i did have a reader that did this and expected the lang it was used with to override #%datum in order to detect these special structs, that would work fine and these syntax objects wouldn’t exist after expansion. But using the reader with a lang that uses the default definition of #%datum would expand it into (quite <stx object>), and that would result in a 3d syntax object surviving to a fully expanded module.


notjack
2017-10-2 22:55:39

So I guess my question is: should the default #%datum form with a 3d syntax object be an error?


lexi.lambda
2017-10-2 22:59:35

Should it be an error? I don’t think it should be an error… not currently, at any rate. Whether or not it will do what you want is a separate question. I’m not entirely sure what “phase” the reader runs at (since it doesn’t really have one, currently), but I would imagine it is different from macroexpansion phases, so your struct might end up being from no phases at all… and it would at least need to be cross-phase persistent to be defined behavior.


notjack
2017-10-2 23:02:43

I think the reader and the expander share namespaces


leif
2017-10-3 01:02:28

@robby Is the indentation settings for racket text% editors defined in framework?


leif
2017-10-3 01:02:44

If so could you point me to it? (Searching the docs appears to have failed me.)


robby
2017-10-3 01:03:10

I don’t know what you mean by indentation settings exactly


robby
2017-10-3 01:04:19

What purpose are you trying to achieve?


leif
2017-10-3 01:05:11

Checking indentation, in specific:


leif
2017-10-3 01:06:05

At the moment I have an object that satisfies racket:text<%>, I can call one of the tabify functions on it to indent it.


leif
2017-10-3 01:06:34

However, I also want the ability to change some of the tabbing rules, much like in the DrRacket preferences window.


leif
2017-10-3 01:06:43

In fact, exactly like in the DrRacket preferences window.


leif
2017-10-3 01:06:50

I’m just looking for a programatic way to do that. :wink:


leif
2017-10-3 01:07:54

If you know how I could do that that would be awesome. :smile: (If not thanks anyway though.)


robby
2017-10-3 01:10:29

preferences:get and preferences:set


robby
2017-10-3 01:10:42

You can avoid updating your own preferences file if you use:


robby
2017-10-3 01:11:18

preferences:low-level-put-preferences and the getter


robby
2017-10-3 01:11:28

(set up a hash table and avoid writing to the file)


robby
2017-10-3 01:11:53

You can look at the difference between the files before and after you make the modification via the drracket gui


robby
2017-10-3 01:12:08

and you probably also want to look in framework/private/main, I believe.


robby
2017-10-3 01:12:12

hth


leif
2017-10-3 01:19:39

Ok, cool


leif
2017-10-3 01:20:06

So basically try it in drracket and check the preferences file to see the exact preference? Cool, much appreciated. :smile:


robby
2017-10-3 01:21:21

or read the code I pointed you to, in order to see what the settings are.


robby
2017-10-3 01:21:23

or both, I suppose


leif
2017-10-3 01:22:51

Cool, thanks.


leif
2017-10-3 01:23:08

Although hmm…the preferences file doesn’t seem to be in my ~/Library/Racket folder.


robby
2017-10-3 01:23:47

See find-system-path


leif
2017-10-3 01:24:07

facepalm ah, thanks.


leif
2017-10-3 01:25:10

~/Library/Preferences…ah, okay. Thanks. :slightly_smiling_face:


leif
2017-10-3 01:32:12

@robby Ah, okay plt:framework-pref:framework:tabify, thanks. :slightly_smiling_face:


robby
2017-10-3 01:32:40

when you call preferences:set you don’t pass the plt:framework-pref part


leif
2017-10-3 01:39:07

just framework:tabify? Makes sense. Thanks a lot for the help.


blerner
2017-10-3 02:12:44

@robby or @leif or anyone who’s worked with images in DrRacket: is there a reason make-bitmap requires its width/height arguments to be strictly positive? Tonight, two students pasted into their code the rendered output of empty-image, i.e. a 0x0 image, and my Racket->text converter choked on it because make-bitmap threw an error.


robby
2017-10-3 02:13:42

I guess one of the underlying bitmap construction operations on one of the platforms won’t create a zero sized bit map


robby
2017-10-3 02:13:59

The image library has a bunch of special cases for this reason.


robby
2017-10-3 02:14:14

(I don’t actually know why tho. But that’s my guess.)


blerner
2017-10-3 02:24:28

gotcha. So in my code, I can use a workaround with (equal? snip 2htdp:empty-image), and short-circuit the problem. but it seemed kinda hackish to me :wink:


leif
2017-10-3 02:47:04

@blerner Ya, fwiw, I suspect Matthew has done the most with that particular bit of the code (bitmap%)


leif
2017-10-3 02:48:14

Although can I ask why you are using bitmap% in the first place?


leif
2017-10-3 02:49:07

(I mean, don’t get me wrong, its frequently the right task for the job, but pict is usually much nicer when it comes to silly edge cases like this. :wink: )


blerner
2017-10-3 02:51:02

I’m using neither; I’m walking the wxme tree of snips, finding the convertibles, and converting them to pngs


blerner
2017-10-3 02:51:22

do you happen to know how to ask a convertible what its width will be, if I try to convert it?


blerner
2017-10-3 02:51:31

assuming I don’t know what type of snip it is, merely that it’s convertible?


leif
2017-10-3 02:52:30

Oh wow, if you’re using convert to convert to a png and you’re getting an error that’s probably a bug.


leif
2017-10-3 02:53:12

So short answer, no, I don’t think you can do that. Long answer, that’s probably a bug…can you give me a sample?


blerner
2017-10-3 02:53:22

so, (convert empty-image 'png-bytes) will trigger the contract error


blerner
2017-10-3 02:53:43

You can rig it with some image snip if you want, but that’s simple enough as it is


leif
2017-10-3 02:56:12

@blerner Interesting, this is certainly a bug.


blerner
2017-10-3 02:56:14

also, really annoyingly: (convert empty-image 'png-bytes 'fallback) doesn’t give me 'fallback, it dies with the contract error, first.


leif
2017-10-3 02:56:16

As per the docs…


leif
2017-10-3 02:56:26

yup


leif
2017-10-3 02:56:31

which is why its a bug. :wink:


leif
2017-10-3 02:57:15

Either: A) It should not say its convertible?, or B) It should return fallback (which is by default an error iirc.)


leif
2017-10-3 02:58:18

Although…its probably a bug in the 2htdp library.


blerner
2017-10-3 02:58:18

I’d rather B: I don’t want image snips to not claim that they’re convertible things, but I do want a decent error-handling mechanism


leif
2017-10-3 02:59:26

Ya, this is almost certainly a bug in 2htdp, for example, when trying to convert blank, I get:


leif
2017-10-3 02:59:30
> (convert (blank 0) 'png-bytes)
#"\211PNG\r\n\32\n\0\0\0\rIHDR\0\0\0\1\0\0\0\1\b\6\0\0\0\37\25\304\211\0\0\0\rIDAT\b\231c\370\377\377?\3\0\b\374\2\376\205\315\2534\0\0\0\0IEND\256B`\202"

leif
2017-10-3 03:00:04

I ‘think’ @matthias manages that library? I’ll talk to him about it tomorrow morning if that works for you?


leif
2017-10-3 03:00:21

(Unless you need something sooner.)


blerner
2017-10-3 03:00:51

well, I can workaround it with a with-handlers on the exn:fail:contract error, but it’s ugly. I’d like a cleaner long-term solution


leif
2017-10-3 03:04:51

@blerner Okay. Fwiw, something like this will solve your immediate problem, I’ll talk to Matthias tomorrow about getting it fixed properly: #lang racket (require (prefix-in file: file/convertible) pict) (define (convert v request [default #f]) (with-handlers ([exn:fail:contract? (λ (e) (case request [(png-bytes) (convert (blank 0) 'png-bytes default)] [else (raise e)]))]) (file:convert v request default)))


blerner
2017-10-3 03:06:11

Thanks. For now, I’m using a similar handler, but I’m not outputting the empty image itself. In a minor sense, it’s better that I handle the error, because a 0-pixel image is very hard to see on a monitor… :slightly_smiling_face:


leif
2017-10-3 03:06:47

LOL, very true. Which is why I always (aka never) use zero-width space characters in my racket variables. :wink:


leif
2017-10-3 03:07:01

Anyway, I need to be up early in the morning, so if that works for the moment I’m off to bed. :slightly_smiling_face:


blerner
2017-10-3 03:07:10

thanks


leif
2017-10-3 03:07:27

Thank you for finding the bug.


blerner
2017-10-3 03:07:44

don’t thank me; thank students with wonky submissions!


blerner
2017-10-3 03:08:18

Found another bug too (filed in git) about indentation and highlighting; not urgent, just weird


soares.chen
2017-10-3 06:56:02

@soares.chen has joined the channel