ppx_utf8_lit icon indicating copy to clipboard operation
ppx_utf8_lit copied to clipboard

Is using attributes and not extension nodes the right way?

Open whitequark opened this issue 10 years ago • 6 comments

If an extension is not activated by some reason, perhaps by mistake, normalization will not happen, which can lead to extremely hard to find bugs.

whitequark avatar May 05 '15 22:05 whitequark

If this is to remain a ppx, certainly. The aim here was more to try to imagine what a compiler integration could look like (one can dream).

dbuenzli avatar May 05 '15 22:05 dbuenzli

Sligthly related to #1.

dbuenzli avatar May 05 '15 22:05 dbuenzli

Certainly it should be attributes? I'm afraid I don't follow you here. Why would it not be safer to use extension nodes?

whitequark avatar May 05 '15 22:05 whitequark

Certainly it should be attributes?

Don't know. Frankly to me the differences between attributes and extension points is not very clear (neither is the manual about that, I remember @gasche having a more clear definition of the distinction between the two but I can't find the quote again). But I have the impression that you wouldn't want extensions points to become part of the language. The syntax is also a little bit heavier in my opinion, though perhaps more clear w.r.t. #1.

Why would it not be safer to use extension nodes?

Didn't pretend that. But if these annotations become part of the language the point is moot.

dbuenzli avatar May 05 '15 23:05 dbuenzli

Oh I see. The difference is that attributes are ignored by the compiler, whereas extension nodes cause a syntax error. So in absence of the corresponding -package, a solution with attributes would silently exhibit wrong behavior, but with extension nodes, it would be a compile error.

Not sure about syntax being heavier: "foo" [@u.nfc] vs [%u.nfc "foo"]. Same number of characters, even.

whitequark avatar May 05 '15 23:05 whitequark

It's true that, in case this becomes a part of the language, the point about forgetting -package becomes moot, though. You still need to watch out for older OCaml versions, but that's much easier.

whitequark avatar May 05 '15 23:05 whitequark