Skip to content(if available)orjump to list(if available)

A Racket alternative to HTML Tidy

A Racket alternative to HTML Tidy

9 comments

·January 10, 2025

8n4vidtmkvmk

Lost me at the second sentence.

> Why go to the trouble of designing clean, semantic markup if you’re just going to slap it all on one line that scrolls horizontally forever?

Is this a formatter for authoring HTML, or for the HTML we send down to the client? Because the latter should be optimized for byte size. No one needs to read that.

neilv

It's a utility procedure that other people will use for various purposes.

Sometimes you end up making a package for just one utility procedure, and sometimes there's a little levity in that documentation:

https://www.neilvandyke.org/tabexpand-scheme/

behnamoh

I like Racket. I don't like Racket's excessive use of symbols: ( [ #:word? word->anotherWord ...

Same goes for Haskell (https://tech.fpcomplete.com/haskell/tutorial/operators/).

neilv

I kinda agree.

The `#:foo` syntax is something that Racket did when it introduced keywords values, to support keyword arguments. So, you'd write:

    (myfunc x y #:foo 42)
when in some other languages you'd write one of:

    myfunc(x, y, foo=42)

    myfunc(x, y, foo: 42)
Personally, I argued for the `#:` to be `:`, like in some other Lisps:

    (myfunc x y :foo 42)
Regarding `->`, it's an ancient Scheme naming convention for identifiers, meaning transform one thing to another, which looks a little ugly, but not a totally bad idea. So you'd have:

    (number->string 42)
rather than `numberToString(42)` or any of the other gazillion function names, methods, special syntax, idioms, or flying leap type coercion used in other languages.

Scheme also has a few other conventions, including suffixing an identifier with a `?` to denote a predicate on a value, such as:

    (positive? 42)
compared to, say, `isPositive(42)`.

The Racket professors added their own conventions in code they write, including making `[` syntactically equivalent to `(`, and then having a convention of when to use bracket vs. parentheses.

I actually privately made my own Racket `#lang` that permitted colon-keywords, and removed the square-bracket equivalence. There shall be no pound-colon-keyword, and I expect there's better uses for square brackets, such as for an heavy use object method/message syntax without having your code full of `send`. For example, instead of Racket's own object system syntax:

    (send myobj mymethodid x y)
you might have:

    [mymethodid myobj x y]
or:

    [myobj mymethodid x y]
Or some other use in various PL research uses of Racket, where you have a language that starts as Scheme, and adds some other semantics for which you don't want special keywords throughout the code. Unused ASCII symbol characters are precious.

andrewflnr

> I actually privately made my own Racket `#lang` that permitted colon-keywords, and removed the square-bracket equivalence.

That's gotta be one of the LISPiest things I've ever heard.

(No disrespect. Godspeed, I wish I could follow.)

shawn_w

`#:name` style keywords are pretty common in Scheme implementations. I've grown to like the style; makes them stand out more visually. (Possibly uniquely, Chicken lets you choose between several different styles; :common-lisp, dssl: and #:sharp-colon)

Making square brackets an alternative to parens is another thing I like (also supported by some Schemes and in R6RS but not R7RS). You don't see it as often but you can also use curly braces as another alternative. Hmm. Maybe they should borrow from perl¹ and have any pair of matched characters count.

1: https://perldoc.perl.org/feature#The-%27extra_paired_delimit...

neilv

I don't know for certain, but I think Racket (PLT Scheme) started both of these. (Scheme implementors do tend to have a strong-minded side, but also tend to be aware of other implementations, and some are willing to borrow smaller details from other implementations, or at least to show they can support that too.)

IIRC, one of the arguments for `#:` in Racket was that one of the SRFIs incidentally kludged `:` keywords for its own purposes, and someone didn't want to break that SRFI. :)