
@shu—hung is ...
supposed to be clickable in the REPL? Cuz I can’t click it.

Yes, but: • The output area is locked, while expanding the S-exps is an editing operation. Therefore (...)
s have to be copied to the prompt area (>
) • S-exp snips don’t respond to clicks. Instead, there is a “expand” option in the right-click context menu.

I don’t see the expand option :neutral_face:

Maybe the context menu can be scrolled down?

In the definition window, if you right click and select “Collapse S-expression”, the same kind of "(…)" snips will appear

It’s funny. I have '(123 (store 456))
.
It’s printed as (123 (...))
And then I can collapse it to (...)
and expand it back to (123 (...))
.
But I can’t expand the inner (...)
.

Ah, a difference could be that I directly sets the global print to sexp-pp

In the definition window: (current-print sexp-pp)
Then in REPL: > '(123 (store 456))
'(123 (...))

There is probably some DrRacket magic that makes the two non-equivalent
EDIT: write-special
works with traces
but doesn’t work in the REPL — replace the line with write-special
with (old-print-hook s display-mode? out-port)
to make it work in REPL. However, old-print-hook
doesn’t work in traces
.

> The output area is locked, while expanding the S-exps is an editing operation. Therefore (…)s have to be copied to the prompt area (> ) Some error messages have ...
that we can click to see more information, right? How does that work while the editor is locked?

It’s probably not a racket:sexp-snip%
but a different DrRacket GUI component

If sexp-snip%
s are more sophisticated, like embedding an editor inside it, then it may be expandable

I just fixed a bug report in Sketching. The Sketch window spawned off screen on Windows. I had used [x display-width] [y 0]
to place the window at the upper, right hand corner. On macOS this works fine. On Windows it was placed outside the screen.
Is there a way to place the frame at the upper, right corner on Windows?


Or is the best approach to create the window and then move it afterwards?

Maybe I don’t understand what you are trying to do, but if you place a window such that its top-left corner is at the display width, I would expect it to be off screen.
Maybe you meant to place the window at [x (- display-width window-width)]
You also need to take into account that on Windows there is an invisible border of approximately 5 pixels around each window — since the windows themselves have no drawn border yet the user needs to be able to click and drag the edge of the window to enlarge it…

Turns out it macOS moves it, so it is visible. You right, the expectation ought to be that it is displayed outside. The problem is that I don’t know the window size until after the frame is created. I didn’t know about the 5 pixel border.
Would it make sense to use the default - but if the window is moved, store the new position on disk to be used for the next program invocation?

Once you have created all the widgets inside the window, and before you show it, call reflow-container
— this will calculate the size of the window

Do we want a Racket online meeting on Saturday? If yes, I’d suggest the time and “place” as mentioned at https://racket-news.com/2021/07/racket-news-issue-52.html#meetups .

That sounds like the proper way.

@christos.perivolaropo has joined the channel

hello, is there any good code formatter that can insert newlines (like racket/pretty) that also respects comments? I am looking for something like clang-format for C/C++, or brittany for haskell, or js-beautify, etc.

There’s places in the racket source code where it seems a tool was used to polish up the code (eg https://github.com/racket/racket/blob/master/racket/collects/syntax/module-reader.rkt#L37L46 )

If a full-fledged condition system is to be implemented in Racket, there are two possible approaches. First would be to enlarge the exception hierarchy where exn is a subtype of conditions that are non-resumable. The second approach is to make conditions a subtype of exn. Not sure which one is better.
I remember there was a proposal for adding conditions and restarts to Scheme a while ago that stood out among competing proposals but unfortunately I’ve forgotten where I saw it.

@christos.perivolaropo I think most people just “select all” and then “indent” in either DrRacker or racket-mode. Also, in DrRacket you can choose to get a “vertical column guide” when your lines are too long.

I am actually using racket-mode in emacs (which also provides an indent-region command). Does the drracket version also align let/cond/match forms or other things like that to help readability?

Yes it does

To be clear, neither will insert newlines for you.

An indenter takes the newlines as givens, and adjusts indentation of each line.

A “pretty printer” effectively throws away all the newlines and indents, and redoes the whole thing, using some parameter for max width.

However the pretty printers I know of do not attempt to handle the special indentation for various special forms (macros) that the indenters do handle.

By convention, in Lisps procedure applications are indented consistently.

But macros might use special indentation.

In some Lisps this can be communicated in the macro definition.

But in Scheme and Racket it’s done “out of band” with special rules in the editor or other tool, saying how to handle various forms.

That’s my hopefully mostly correct, Cliff Notes summary. :slightly_smiling_face:

(seems correct to me, including from the vim side)

Question: I have been having issues with setting file-position
in different contexts. I was finally able to determine that the difference in behavior was triggered by enabling line counting via port-count-lines!
. If line counting has been enabled for a port is it required to use set-port-next-location!
in order to actually get the file position to change?

Are you using port-next-location
to retrieve the current location or are you using file-position
to get the reading position?

I use file-position
to get the current location, but I am fiddling around inside parser-tools, which might be using port-next-location
which might explain the discrepancy?

Could be! I know nothing about the parser tools :slightly_smiling_face:

But yes, I suspect the port-next-location counting has an independent counter not sync’d with file-position.

File-position should still set the reading position at OS level, though

It does. However they do get out of sync, and it looks like parser-tools is using port-next-location for some things.

port-next-location
does have a separate tracker that is updated independently, I’m still having issues, but they are new issues, so progress. Thanks!

Looks like there are more subtle points: https://docs.racket-lang.org/reference/linecol.html#%28def._%28%28quote._~23~25kernel%29._port-next-location%29%29
One is counting in bytes, while the other is counting in characters (in UTF–8). This matters especially when there are non-ASCII characters.

hrm, I will cross that bridge when I get there, for now it seems that everything is synced up and happy if I set-port-next-location!
to 1
more than what I do with the file position, but that will clearly get out of sync at some point so I will transition all the math over to port-next-location
to avoid issues in the future.

@migueldrums741 has joined the channel

Hi everyone, happy to join to this group. Greetings from Venezuela :flag-ve:. Can someone give recommends to create a Web Site with Racket? Some guide or some advice. Thank you in advance. Sorry for my rookie question.

Welcome!
There’s this guide: https://docs.racket-lang.org/continue/\|https://docs.racket-lang.org/continue/

Wouldn’t you say that Racket is the ideal language for software engineering? Programming is about conquering complexity and the ultimate way to do this is by writing interpreters and compilers. Dr. Felleisen has promoted Racket as a language oriented language. If racket is built to write DSLs quickly and if metalinguistic abstraction is the ultimate abstraction then isn’t Racket the ideal language? In addition to this Racket is academic, has a test suite integrated with the language. For these reasons I think I’m switching from Common Lisp to Racket. Do you guys agree or disagree?

i never used common lisp and you’re asking in a racket channel so there are probably some biases. I think while its good that racket provides very good facilities for those who want to explore language design, creating a DSL is the last thing I reach for because it require a lot of maintenance and documentation for users, etc. see : http://www.winestockwebdesign.com/Essays/Lisp_Curse.html the lisp curse

Yeah, I’m not into the “Language Oriented Programming” thing either. I’m more in favor of creating tools in an ecosystem the user is already familiar with.