Hacker News new | past | comments | ask | show | jobs | submit login

Right.

For a macro which only implements a 'simple' syntactic transformation, I would expect that I need to understand the semantics anyway. Additionally I need to understand the syntax it implements.

What I don't want at all, is to macroexpand macro forms. If I need to macroexpand those, then I would do this for debugging, when there is something wrong during expansion or with the generated code. I would also do the expansion not in my head, but using a function called 'macroexpand'.

For example as a reader, I don't want to macroexpand the following form in my head:

    (with-open-file (foo "bar.text")
      (read foo))
What I really want is to understand the syntax of WITH-OPEN-FILE and semantics of such a form. To what it transforms itself is the least important thing I (as a code reader) want to know when dealing with macro forms.

* it's a WITH- type macro which sets up a scope.

* a WITH- type macro usually expects a variable, something which helps creating an object that is bound to the variable and a bunch of options

   (foo-var "the-file-name.text" :direction :input)
* it then expects a body, a sequence of forms, where the variable FOO-VAR is bound to a file

That's the syntax.

The semantics is that at runtime it opens a file as a stream and makes sure that on all forms of exit, the stream gets closed.

To what form this actually expands (even if it is a simple transformation) is uninteresting and may be different from implementation to implementation.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: