re: It's Just Syntactic Sugar VIEW POST

FULL DISCUSSION
 

As a compiler writer I have a different opinion of what "syntactic sugar" actually is. To me, it's something that I can implement in the parsing and syntax tree generation phase.

That is, consider the stages Leaf uses to compile code:

  1. Parse
  2. Convert parse-tree into syntax-tree
  3. Add types to syntax-tree
  4. Lower to Leaf-IR
  5. Lower to LLVM-IR
  6. Emit target code

Anything I can implement in phases 1-2 is definitely syntactic sugar. It didn't require any changes in the langauge's abstract machine, or typing rules.

Some things in Step 3 I'd also consider syntactic sugar if they are plain rewriting rules. These are almost like parsing rules, but required a higher level of logic than the syntax tree conversion could do.

At a user level this would imply a feature that can be completely described in reference to other features or already existing concepts. It doens't add any new power or flexibility to the language. It certainly can make it nicer to use though.

 

As a not compiler writer in the slightest (or a compiler reader for that matter) this made perfect sense. Thank you.

code of conduct - report abuse