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

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:

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

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

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

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

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

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.

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

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

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

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

Why is the convention to use hyphens rather than underscores?

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

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

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:

lol

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

Also you can write - without pressing <shift>

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?

@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

If the target is HTML, can’t you just use elem
that pretends to be <img>
?

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.

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”

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

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 I’d start here: http://docs.racket-lang.org/scribble/core.html?q=scribble#%28mod-path._scribble%2Fhtml-properties%29

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?)

see the one about convertible

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 ...])

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

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

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

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

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

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

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

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

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

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

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

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

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

It will complain

Because it’ll see the extra output

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

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

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

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 ^

@greg where did you put the parameterization?

Inside the main
submodule around its entire contents.

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

Yes.

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

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.

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

Oh.

That seems straightforward.

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

and then put the parameterize around the dynamic-require

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

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

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

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

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

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

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

because the printouts are in the contract system

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.

http://www.gnu.org/software/emacs/manual/html_node/elisp/Output-from-Processes.html suggests that there’s a way

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

glad that was easy

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

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?

sure, certainly

thanks for looking into it

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 has joined the channel