My language design is bad and I should feel bad [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Mon 2017-02-20 20:09
My language design is bad and I should feel bad
LinkReply
[identity profile] cartesiandaemon.livejournal.comTue 2017-02-21 23:23

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" :)

Link Reply to this | Thread
[personal profile] simontWed 2017-02-22 06:18

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 [livejournal.com profile] 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, not affecting the semantics of the operation, so it's OK to relegate it to not being flagged up by a mandatory syntactic distinction. (Indeed, the difference between the two kinds of thing is already blurred in languages like Python, where on the one hand you can subclass dict to make it automatically fill in values for missing keys on the first access attempt, and on the other hand, decorate functions to make them automatically memoised.)

Of course, the other meaning of 'function' in programming – the mechanistic one of 'save all my current state, go off and run arbitrary other code, come back with or without a return value, who knows what happened in between' – doesn't give rise to the same argument...

Link Reply to this | Parent
[identity profile] fivemack.livejournal.comThu 2017-02-23 10:02

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.

Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]