A thought which came up on Libera.chat / #perl just now:
In very maths-heavy code (e.g. involving 3D coordinates) it's often
useful to have things like X/Y/Z or i/j/k as your 3 basis vectors.
Expressions like X+Y or X-Z are fine, but perl will trip up over
Y-X because `-X` is a filetest operator; parsing this as a call to
Y( -X ) instead of Y() - X(). You have to play whitespace games
like `Y - X` or parens like `Y-(X)`.
Similar problems happen around -k.
Since it is highly unlikely you'd need to perform filesystem tests
during such mathsy code, it would be really handy if the filetest
`-x`-like operators were controlled by a (default-on) feature flag,
that could be turned off in such code:
no feature 'filetests';
such that e.g.
sweep(+X, -X);
sweep(+Y, -Y);
sweep(+Z, -Z);
now does what I meant.
I'm sure there's probably other unrelated fields [pardon the pun] in
which it'd be handy to have regular single-letter functions, for
which these filetests also get in the way.
[.[.Not directly related to this particular request, but a possible
extension idea is to permit the "parse this numerical literal" part of
the parser to accept some nicer notation, so you can write things like
sweep(3i, -3i);
sweep(2j+3k, -k); # instead of -1k
etc...
for which it would similarly be handy to turn off the parser's `-k`
operator]]
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
In very maths-heavy code (e.g. involving 3D coordinates) it's often
useful to have things like X/Y/Z or i/j/k as your 3 basis vectors.
Expressions like X+Y or X-Z are fine, but perl will trip up over
Y-X because `-X` is a filetest operator; parsing this as a call to
Y( -X ) instead of Y() - X(). You have to play whitespace games
like `Y - X` or parens like `Y-(X)`.
Similar problems happen around -k.
Since it is highly unlikely you'd need to perform filesystem tests
during such mathsy code, it would be really handy if the filetest
`-x`-like operators were controlled by a (default-on) feature flag,
that could be turned off in such code:
no feature 'filetests';
such that e.g.
sweep(+X, -X);
sweep(+Y, -Y);
sweep(+Z, -Z);
now does what I meant.
I'm sure there's probably other unrelated fields [pardon the pun] in
which it'd be handy to have regular single-letter functions, for
which these filetests also get in the way.
[.[.Not directly related to this particular request, but a possible
extension idea is to permit the "parse this numerical literal" part of
the parser to accept some nicer notation, so you can write things like
sweep(3i, -3i);
sweep(2j+3k, -k); # instead of -1k
etc...
for which it would similarly be handy to turn off the parser's `-k`
operator]]
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/