mark.warren
2018-12-5 08:04:39

@pocmatos I would agree with @dario.hamidi why would the hash table that was constructed as mutable become immutable because it was put in a struct? If you want the hash table immutable then create it that way.


pocmatos
2018-12-5 08:11:18

Nice to see others have different opinions on this. My intuition goes exactly the opposite way. If I mark my struct as immutable, I expected that to be propagated to its values. But I guess if the current case is obvious to everybody else, fine with me. :slightly_smiling_face:


mark.warren
2018-12-5 08:15:05

I just see it as flexible, create your data the way you want it. :grin:


notjack
2018-12-5 10:07:06

@pocmatos was your intuition influenced by how const works in c/c++?


pocmatos
2018-12-5 10:10:08

@notjack not sure… I was not totally surprised about it but was not what my intuition was telling me it should be. My brain was telling me that if I have two immutable transparent structures writing the same, they will always write the same - but turns out not to be true.


notjack
2018-12-5 10:16:00

@pocmatos I suspect that’s related to the way read and write are presented in lisps as the de facto serialization and deserialization mechanism


notjack
2018-12-5 10:18:04

I don’t think it’s a good idea to mix together serialization and the text representation of things used by the repl / logs / debugging tools


jerome.martin.dev
2018-12-5 10:21:39

For me, I see a struct as having immutable references to mutable objects. So in this case, you cannot make the struct point to another hash, but you can access the hash and modify it.


mark.warren
2018-12-5 11:16:47

@pocmatos I may be misunderstanding but you can just make the hash in the struct immutable and that solves the problem doesn’t it?


pocmatos
2018-12-5 13:13:20

@mark.warren that’s correct. I don’t find this behaviour a problem by the way. But I found it counter-intuitive. However, as I just learned, I seem to be alone on this one. :slightly_smiling_face:


pocmatos
2018-12-5 13:13:52

@jerome.martin.dev Might be the best mental model for this situation.


mark.warren
2018-12-5 13:15:08

I guess coming from an object oriented Java background where nothing is immutable by default has set my way of thinking.


me1
2018-12-5 17:15:47

Why is the convention to use hyphens rather than underscores?


samth
2018-12-5 17:17:43

@me1 it’s a very long-standing Lisp tradition, mostly because hyphens are the usual thing you write in English, and they work in Racket (and other Lisps) whereas they don’t work in C or JavaScript or …


me1
2018-12-5 17:19:02

you can’t do multi-word adjectives, though (see what I did there :wink:)


samth
2018-12-5 17:23:20

I’m not going to speculate about what you can do in english, since it’s often more than you’d expect :slightly_smiling_face:


me1
2018-12-5 17:28:37

lol


me1
2018-12-5 17:28:56

yeah I’m an essayist and editor so it kind of bugs me :eyes:


soegaard2
2018-12-5 17:29:13

Also you can write - without pressing <shift>


blerner
2018-12-5 18:35:56

Question about Scribble + picts: is there a pict constructor/combinator/utility function/whatever that would allow me to specify the alt-text of the image that gets rendered , when the surrounding scribble document gets rendered to HTML?


samth
2018-12-5 18:44:56

@blerner I don’t think there’s a pict function for that, and I do see the issue since you’d really want it in something produced by say examples where you can’t adjust the HTML directly


sorawee
2018-12-5 18:46:33

If the target is HTML, can’t you just use elem that pretends to be &lt;img&gt;?


blerner
2018-12-5 18:50:44

The scenario I have is writing documentation for a website, and I want to say “Click the [blue "Help" button] to …”, where [blue "Help" button] is a pict function I wrote that generates a blue rounded rectangle with the text “Help” in it. But ironically, while this image is useful for sighted users, it’s counterproductively inaccessible to vision-handicapped users.


blerner
2018-12-5 18:51:32

So I have the flexibility to revise that function and wrap it somehow with scribble-related magic to produce the alt-text “blue Help button”


samth
2018-12-5 19:17:31

ok, then I think you can do it with scribble properties


blerner
2018-12-5 19:21:43

Could you give me a code-hint for that? Assume that I’m starting with a (define (button text color) (filled-rounded-rectangle ... color ... text ...)), and that I’m happy to pass around extra arguments as needed. What scribble thing do I wrap that in?



blerner
2018-12-5 19:27:47

Those apply to individual elements, as @sorawee mentioned, right? I can’t apply that directly to the result of a pict? (I guess I’m asking, how does a pict get turned into pre-content in scribble, so I know what I need to wrap?)


samth
2018-12-5 19:32:08

see the one about convertible


blerner
2018-12-5 19:36:01

Ok. Am tracing through html-render.rkt now, I’ve found the render-convertible-as struct, and now I see the (define/private (render-as-convertible ...) method, which hard-codes a result of (img ([src ...] [alt "image"] [width ...] [height ...])


blerner
2018-12-5 19:36:32

the hardcoded alt-tag there indicates to me that I’m kinda stuck…


samth
2018-12-5 19:39:13

does it not use the render-convertible-as property?


blerner
2018-12-5 19:42:29

That’s what render-as-convertible does: it recognizes png-bytes and png@2x-bytes, converts the pict to a png as a bytestring, calls install-file on it, and then hardcodes the "image" alt-text


blerner
2018-12-5 19:42:51

Since render-as-convertible is define/private, though, I can’t override it to change the filename or the alt-text string


samth
2018-12-5 19:43:34

I think we’re miscommunicating. There’s a style property struct called render-convertible-as which suggests that it allows you to control exactly what you want


samth
2018-12-5 19:44:00

Presumably the implementation looks for that somewhere, and calls the relevant functions.


blerner
2018-12-5 19:46:34

yes, exactly. The options are 'png-bytes or 'svg-bytes. Those are handled by https://github.com/racket/scribble/blob/master/scribble-lib/scribble/html-render.rkt#L1444-L1482


blerner
2018-12-5 19:47:36

the last four lines of that are the hardcoded img tag that results from converting the pict to a png


samth
2018-12-5 22:18:45

@greg I think racket-mode should ignore output on stderror


greg
2018-12-5 22:28:27

@samth IIRC Emacs shell processes get stdout and stderr mixed together, so can’t “unsplit” and filter there. But the racket-mode back-end could parameterize current-error-port to open-output-nowhere in the first place, I guess. But. Do you mean ignore as in don’t show it to the user? And if so, why?


samth
2018-12-5 22:29:18

I mean, it shouldn’t get confused by spurious output when that output is on stderr


greg
2018-12-5 22:31:27

I agree that racket-mode shouldn’t get confused :smile: but I’m not sure what problem you mean? Is there some specific example?


samth
2018-12-5 22:38:55

Put a eprintf inside some racket/base code. Then use C-c x f


samth
2018-12-5 22:39:03

It will complain


samth
2018-12-5 22:39:16

Because it’ll see the extra output


greg
2018-12-5 22:45:13
#lang racket/base
(eprintf "Hi\n")

I do C-c x f and get the “Open require path: ” prompt. I type things. It works. I don’t follow.


samth
2018-12-6 00:36:35

@greg sorry I missed this. I mean add that to racket/base.rkt


samth
2018-12-6 00:36:52

So that it prints during the code that racket-mode runs


greg
2018-12-6 02:24:10

Ah. Interesting. So I can reproduce that. Note it’s limited to how that C-c C-x C-f aka racket-open-require-path command works. It actually runs this racket file — https://github.com/greghendershott/racket-mode/blob/master/racket/find-module-path-completions.rkt — and pipes text back and forth. To that file I tried parameterizing error-output-port to open-output-nowhere — but racket/base.rkt is loaded and does the eprintf before that parameterization has taken effect. So I’ll have to do this — filter stderr — on the Emacs side. That didn’t use to be possible or at least easy AFAIK but I"ll check again. @samth ^


samth
2018-12-6 02:25:12

@greg where did you put the parameterization?


greg
2018-12-6 02:25:47

Inside the main submodule around its entire contents.


samth
2018-12-6 02:26:15

ok and you just run that with racket find-module-path-completions.rkt?


greg
2018-12-6 02:26:23

Yes.


samth
2018-12-6 02:26:57

So here’s an answer which you might or might not like


greg
2018-12-6 02:27:20

This predates the newer “command server” where things go via TCP, is one reason it does this. Also I want the typing speed to be fast, and I’m not sure even the new way would be as fast as direct text pipe. But I could try.


samth
2018-12-6 02:27:28

write that file in ’#%kernel around a submodule that does the work that’s written in racket/base


greg
2018-12-6 02:27:42

Oh.


greg
2018-12-6 02:28:27

That seems straightforward.


samth
2018-12-6 02:28:35

so (module completions '#%kernel (module go racket/base ...) (module* main '#%kernel (dynamic-require '(submod "completions.rkt" go) #f)


samth
2018-12-6 02:28:46

and then put the parameterize around the dynamic-require


samth
2018-12-6 02:28:58

except that you can’t use parameterize in ’#%kernel


samth
2018-12-6 02:29:21

so you could either mutate the parameter and feel dirty, or use the expansion of parameterize and feel dirty


samth
2018-12-6 02:29:58

also open-output-nowhere isn’t actually in ’#%kernel


samth
2018-12-6 02:30:14

also that doesn’t help when I add eprintf to the runtime system


greg
2018-12-6 02:30:49

I was going to ask, what if you or Matthew does an eprintf in #%kernel, but at least it would help with racket/base.


greg
2018-12-6 02:31:11

Well, maybe I should look again how to tackle it on the Emacs side.


samth
2018-12-6 02:31:30

certainly it would help my current issue which is just the use of racket/match


samth
2018-12-6 02:31:44

because the printouts are in the contract system


greg
2018-12-6 02:31:48

Plain vanilla process buffers mix them, but there’s probably a lower-level way I didn’t know about when I last looked at this N years ago.



greg
2018-12-6 02:48:58

@samth https://github.com/greghendershott/racket-mode/issues/345 I pushed https://github.com/greghendershott/racket-mode/commit/05a439bf716e001422739deda4a2f62b7658d0c7 which fixes it for me. Waiting for all-green from Travis CI, then will merge to master, then MELPA will update in low-number-of-hours. If you like you could hack your .el file locally in the meantime (it’s a simple diff).


samth
2018-12-6 02:49:53

glad that was easy


greg
2018-12-6 02:51:34

Me, too. Now I’d better go delete (eprintf "hi it me") from my racket/base.rkt before I forget. :smile:


greg
2018-12-6 02:55:04

Oh carp. make-process was added in Emacs 25.1 but I’m still supporting back to 24.3. Welp. @samth I might not be able to resolve this tonight but hopefully that patch could tide you over locally for now?


samth
2018-12-6 02:55:23

sure, certainly


samth
2018-12-6 02:55:27

thanks for looking into it


greg
2018-12-6 02:56:24

You’re welcome, but I feel like it’s a small thing in return for making it easier for you to keep making Racket even more awesome..


daniyark26
2018-12-6 04:16:55

@daniyark26 has joined the channel