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

A Racket alternative to HTML Tidy

A Racket alternative to HTML Tidy

2 comments

·January 10, 2025

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.