Closed GuillaumeGomez closed 2 weeks ago
How about not removing or re-implementing them as filters or functions, but renaming them like:
|
→ bor
&
→ band
^
→ xor
Or the ISO 646 way:
|
→ bitor
&
→ bitand
^
→ xor
Our parser does the lexing and parsing in one step, so you could still have expressions like {{ bor band xor }}
→ write!(w, "{}", self.bor & self.xor)
without syntax clashes. (I would still advise against it, though. :) )
Hum. It's an alternative I didn't think of. Although it's also an extension of syntax. I personally tend to prefer to keep the syntax small if possible. There is no direct equivalent of {{ var call other_var }}
, except for math operations like {{ var + other_var }}
. I'm once again not convinced. :laughing:
I can tell that there are actually strange people out there, who do need bit-operators in their template code, because they use SQL integer fields like flags. I know that, because I do that sometimes. :) I don't think that it should be made too difficult to do bit tests.
And I actually like languages that use fewer "special characters" like ^ & |
. It takes me much longer to write &&
than typing and
. Maybe only milliseconds longer, but you type &&
and ||
a lot over the day.
Well, if you have a use case for it, then it's fine by me! Let's go for the ISO 646 way then!
It is something I expect to be rarely used in templates and it makes some syntax errors very confusing, like:
In this case, the only difference between making an
or
binary operation or applying a filter ona
are the whitespace characters around|
.Instead, I suggest to just remove them and eventually add them as filters (I'm not convinced it's worth it though but why not).
I don't include other mathematical operations (like
+
,/
,*
) in this removal though as there is no syntax ambiguity in this case as far as I know.What do you think @Kijewski?