My language design is bad and I should feel bad

Feb 20, 2017 20:09


Over the weekend, I realised, extremely belatedly, that the expression language I designed for my free-software project spigot has a grammar bug. Specifically, it's a context-dependency analogous to the C typedef bug: the same expression can parse differently depending on whether a given identifier is currently defined to be a function or a ( Read more... )

Leave a comment

Comments 4

deborah_c February 21 2017, 09:01:45 UTC
And then there are FORTRAN FORMAT statements, measured against which you're positively angelic...

Reply


cartesiandaemon February 21 2017, 23:23:22 UTC
I did not follow all the parsing details. I want to read that through in more detail at some point.

But it also occurred to me, it should *look* obvious, I don't know if there are any heuristics you use in naming variables vs functions that could be promoted to a language requirement.

OTOH, I guess, function-call operator for ints could be defined to be multiply :)

Or, programmers could suck it up and figure out a way to use different sorts of bracket for "invoke function" from "collect expressions together" :)

Reply

simont February 22 2017, 06:18:35 UTC
I don't know if there are any heuristics you use in naming variables vs functions that could be promoted to a language requirement.

And you manage to make it look like coincidence that you say this just below deborah_c's comment about Fortran! :-)

Or, programmers could suck it up and figure out a way to use different sorts of bracket for "invoke function" from "collect expressions together" :)

Oddly, I did have the weird thought some time last year that - at least for functions in the true mathematical sense, i.e. no side effects and always the same output for the same input - square brackets might be quite appropriate in a computing context.

Because, mathematically speaking, a function is a static collection of (input,output) pairs, i.e. it's basically the same as an array or dict/map/hash - better yet, an immutable one. So it should have the same syntax as an array lookup!

The fact that in programming the thing we call 'function' computes each result on demand whereas 'map' stores them all in advance is a mere implementation distinction ( ... )

Reply

fivemack February 23 2017, 10:02:01 UTC
Mathematica decided to use [] for invoke-function and () only for grouping (with {} for list construction and [[]] for index-into-list), so there's a half-reasonable-but-weird precedent for your last suggestion.

Reply


Leave a comment

Up