Why is ccall syntax?

Good question. There’s a few possible answers…

The basic answer

It doesn’t need to be syntax. @ccall is a more recent and much more attractive syntax for the same thing which doesn’t need special support from the parser or lowering.

The historical answer

ccall dates from very early in Julia’s development. Perhaps around this commit where it was first added to the runtime or this commit where the syntax became more similar to its current form.

This was back when Julia source code was still stored in .j files, and the first ccall commit was before macros were even implemented as part of this commit.

The pedantic answer

ccall is parsed in the same way as a normal function call and it’s represented the same way in the AST. So it’d be somewhat reasonable to say it’s not special syntax at all. (This is almost true, though I admit there’s some special processing for the name ccall as part of syntax lowering. I’m not 100% sure whether this is essential or just a convenient place to put this.)

7 Likes