4 ms·
> Something like this: > : h1 ( s -- ) "<h1>" emit . "</h1>" emit ; > "Hello, World!" h1 So, what’s the difference between . and emit? It seems both take
by Someone 5mo ago
> 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?
- nine_k 5mo agoThere'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.
- wizzwizz4 5mo agoIt looks like it's the opposite: `.` does HTML escaping, whereas `emit` is raw.
- FarmerPotato 5mo agoDot is Forth convention for "print" where a single . means print integer. .S (pronounced "dot S" or "print S") is for strings. Both expect input from the stack. ." Begins a literal string you want printed immediately. .S is a word that prints the stack (not destructively) pronounced "print stack" EMIT in Forth prints one ASCII character (which byte value comes from the stack). You are free to redefine whatever you like --it's your own language! Most of the punctuation in Forth has conventional meanings that help (a little) reading comprehension. DECIMAL : STAR 42 EMIT ; : STARS ( n -- ) 0 DO STAR LOOP ; Type 5 STARS ***** ok