frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Extending a Language – Writing Powerful Macros in Scheme

https://mnieper.github.io/scheme-macros/README.html
92•textread•10mo ago

Comments

neilv•10mo ago
A few formatting changes might make this advanced example easier to understand:

    (define-syntax trace-let
      (syntax-rules ()
        [(trace-let name ([var expr] ...) body1 ... body2)
         (let f ([depth 0] [var expr] ...)
           (define name
             (lambda (var ...)
               (f (+ depth 1) var ...)))
           (indent depth)
           (display "(")
           (display 'name)
           (begin
             (display " ")
             (display var))
           ...
           (display ")")
           (newline)
           (call-with-values
               (lambda ()
                 body1 ... body2)
             (lambda val*
               (indent depth)
               (fold-left
                (lambda (sep val)
                  (display sep)
                  (display val)
                  " ")
                "" val*)
               (newline)
               (apply values val*))))]))
The biggest one is to make the rule template pattern variables all-uppercase. I also made a few other tweaks, including using indentation a little more, and naming the named-`let` variable as "loop" (I usually name it `loop` or prefix the name with `loop-` if there's more than one):

    (define-syntax trace-let
      (syntax-rules ()
        ((trace-let NAME ((VAR EXPR) ...) BODY1 ... BODY2)
         (let loop ((depth 0)
                    (VAR   EXPR) ...)
           (define NAME
             (lambda (VAR ...)
               (loop (+ depth 1) VAR ...)))
           (indent depth)
           (display "(")
           (display (quote NAME))
           (begin (display " ")
                  (display VAR)) ...
           (display ")")
           (newline)
           (call-with-values (lambda ()
                               BODY1 ... BODY2)
             (lambda val*
               (indent depth)
               (fold-left (lambda (sep val)
                            (display sep)
                            (display val)
                            " ")
                          ""
                          val*)
               (newline)
               (apply values val*)))))))
Incidentally, all-uppercase Scheme pattern variables is one of the all-time best uses of all-uppercase in any language. Second only to all-uppercase for the C preprocessor, where a preprocessor macro can introduce almost arbitrary text. Using all-uppercase for constants in some language that has constants, however, is an abomination.

(My suspicion of why Java did all-caps is that they were developing a language for embedded systems developers who were currently using C and C++, and they wanted to make it superficially look similar, even though it was an entirely different language. And then, ironically, the language ended up being used mostly by the analogue of a very different developer of the time: corporate internal information systems developers, who, as a field, didn't use anything like C. It's too late to save Java, but to all other language and API developers, please stop the insanity of all-caps constants, enum values, etc. It's not the most important thing that needs to jump out from the code above all other things.)

Y_Y•10mo ago
FWIW, all-caps makes this look much worse to me. I understand that people like things like Hungarian notation, arrows over vector names, and shouting Common Lisp symbols. I understand the argument that it can make reading easier. I just can't appreciate that benefit, and it seems to me an ugly hack which obscures the abstract and general symbolic manipulation going on.

This is all highly subjective of course, de gustibus non disputandem.

neilv•10mo ago
You mean aesthetically, in that interspersed all-caps makes the code visually less soothingly sensual?

I can sympathize, but let me make a non-aesthetic argument...

In large blocks of code, with all-caps, you can see at a glance where all the template substitutions are happening, and also instantly know as you're reading code what are variables and what are template substitutions?

I'm asking because one of my realizations in recent years is that not everyone reads or sees code the same way.

For example, maybe some people are stronger "visual" and some people are stronger "verbal".

For another example of a different in how people perceive and think, some people can visualize an object in their mind almost as if they're looking at it, but other people can only know and describe what it looks like without bringing a visual of it into their head.

With the benefit of the all-caps, I can glance at this and immediately see much of the structure of the template. Without all-caps, I'd have to work harder to find all the pattern variables, and the structure would be obscured.

For a bit kludgy practical matter, as I'm quickly looking at pieces of code in a template, with all-caps, I can look at a fragment of code in isolation and know what are and aren't pattern variables. Without that, I have to go read the top of the template clause (and read through any syntactic scopes of `let-syntax`) and get that in my head, until I get to the fragment of code I originally wanted to look at.

IDE support can make this unnecessary, with a hypothetical great IDE, with familiar syntax coloring. But still, if there is one thing that all-caps should be reserved for, it's something like this.

With all-caps, your code can be sensual, and the jolting all-caps bits are look out, potentially arbitrary code gets pasted into here.

Y_Y•10mo ago
Since you asked, my objection is both aesthetic and semantic, though I was really referring to the semantic part above.

I think you've hit the nail on the head with this visual vs. verbal distinction.

I can add a few clarifying details. I don't use IDEs as much as basic text editors maybe with highlighting, and I try not to rely on any fancy features. It does worry me that the allcaps use you describe is (afaik) not known to the editor or interpreter, so if you make a mistake or the symbol gets out of sync with its meaning (re: pattern variables) you may have a false signal. Finally I'll say that in the end I can't suggest a good way to treat these special variables, and so maybe I don't get it, or tastes like mine would be better served by a different formalism for macros.

mnemenaut•10mo ago
https://github.com/rogerturner/scheme-macros/blob/main/examp... shows stepwise development of a trace-let [the `(example: (fn arg) => result)` forms are tests - see check-examples library]

Create value for others and don’t worry about the returns

https://geohot.github.io//blog/jekyll/update/2026/03/11/running-69-agents.html
94•ppew•1h ago•25 comments

Zig – Type Resolution Redesign and Language Changes

https://ziglang.org/devlog/2026/#2026-03-10
150•Retro_Dev•5h ago•49 comments

U+237C ⍼ Is Azimuth

https://ionathan.ch/2026/02/16/angzarr.html
251•cokernel_hacker•8h ago•24 comments

Julia Snail – An Emacs Development Environment for Julia Like Clojure's Cider

https://github.com/gcv/julia-snail
47•TheWiggles•2d ago•6 comments

Cloudflare crawl endpoint

https://developers.cloudflare.com/changelog/post/2026-03-10-br-crawl-endpoint/
237•jeffpalmer•8h ago•98 comments

Tony Hoare has died

https://blog.computationalcomplexity.org/2026/03/tony-hoare-1934-2026.html
1692•speckx•16h ago•216 comments

Agents that run while I sleep

https://www.claudecodecamp.com/p/i-m-building-agents-that-run-while-i-sleep
297•aray07•11h ago•287 comments

Yann LeCun raises $1B to build AI that understands the physical world

https://www.wired.com/story/yann-lecun-raises-dollar1-billion-to-build-ai-that-understands-the-ph...
425•helloplanets•22h ago•357 comments

RISC-V Is Sloooow

https://marcin.juszkiewicz.com.pl/2026/03/10/risc-v-is-sloooow/
207•todsacerdoti•10h ago•199 comments

Writing my own text editor, and daily-driving it

https://blog.jsbarretto.com/post/text-editor
73•todsacerdoti•5h ago•15 comments

SSH Secret Menu

https://twitter.com/rebane2001/status/2031037389347406054
149•piccirello•1d ago•52 comments

Support for Aquantia AQC113 and AQC113C Ethernet Controllers on FreeBSD

https://github.com/Aquantia/aqtion-freebsd/issues/32
4•justinclift•4d ago•2 comments

Standardizing source maps

https://bloomberg.github.io/js-blog/post/standardizing-source-maps/
15•Timothee•2h ago•1 comments

Debian decides not to decide on AI-generated contributions

https://lwn.net/SubscriberLink/1061544/125f911834966dd0/
315•jwilk•16h ago•240 comments

Launch HN: RunAnywhere (YC W26) – Faster AI Inference on Apple Silicon

https://github.com/RunanywhereAI/rcli
203•sanchitmonga22•13h ago•124 comments

Mesh over Bluetooth LE, TCP, or Reticulum

https://github.com/torlando-tech/columba
74•khimaros•12h ago•8 comments

Universal vaccine against respiratory infections and allergens

https://med.stanford.edu/news/all-news/2026/02/universal-vaccine.html
201•phony-account•8h ago•70 comments

Levels of Agentic Engineering

https://www.bassimeledath.com/blog/levels-of-agentic-engineering
146•bombastic311•22h ago•73 comments

TADA: Fast, Reliable Speech Generation Through Text-Acoustic Synchronization

https://www.hume.ai/blog/opensource-tada
3•smusamashah•1h ago•0 comments

FFmpeg-over-IP – Connect to remote FFmpeg servers

https://github.com/steelbrain/ffmpeg-over-ip
165•steelbrain•12h ago•55 comments

EQT eyes potential $6B sale of Linux pioneer SUSE, sources say

https://www.reuters.com/business/eqt-eyes-potential-6-billion-sale-linux-pioneer-suse-sources-say...
42•shscs911•1d ago•14 comments

Meta acquires Moltbook

https://www.axios.com/2026/03/10/meta-facebook-moltbook-agent-social-network
473•mmayberry•16h ago•313 comments

Roblox is minting teen millionaires

https://www.bloomberg.com/news/articles/2026-03-06/roblox-s-teen-millionaires-are-disrupting-the-...
107•petethomas•3d ago•115 comments

Invoker Commands API

https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API
78•maqnius•2d ago•15 comments

Launch HN: Didit (YC W26) – Stripe for Identity Verification

61•rosasalberto•15h ago•59 comments

Exploring the ocean with Raspberry Pi–powered marine robots

https://www.raspberrypi.com/news/exploring-the-ocean-with-raspberry-pi-powered-marine-robots/
77•Brajeshwar•3d ago•9 comments

Pike: To Exit or Not to Exit

https://tomjohnell.com/pike-solving-the-should-we-stop-here-or-gamble-on-the-next-exit-problem/
10•dnw•2d ago•2 comments

Bippy: React Internals Toolkit

https://www.bippy.dev/
31•handfuloflight•2d ago•6 comments

After outages, Amazon to make senior engineers sign off on AI-assisted changes

https://arstechnica.com/ai/2026/03/after-outages-amazon-to-make-senior-engineers-sign-off-on-ai-a...
537•ndr42•17h ago•429 comments

We are building data breach machines and nobody cares

https://idealloc.me/posts/we-are-building-data-breach-machines-and-nobody-cares/
117•idealloc_haris•16h ago•43 comments