logoalt Hacker News

Someonetoday at 7:22 PM1 replyview on HN

> Something like this:

> : h1 ( s -- ) "<h1>" emit . "</h1>" emit ;

> "Hello, World!" h1

So, what’s the difference between . and emit? It seems both take a string and output it to the HTML of the page. If so I don’t see why that couldn’t be

  : h1  ( s -- )  "<h1>" . .  "</h1>" . ;
We also have:

  "2026-05-21T14:00:00Z"  "May 21, 2026"  dt-published
where, I think, the idea is to always have the two strings consistent with each other. If so, why require the blog writer to do that conversion?

Replies

nine_ktoday at 7:48 PM

There's no docs or implementation, but I'd say that `.` in Forth is a generic way to print something, and `emit` may do more work, like HTML escaping.

show 1 reply