Inconsistent comma requirements
Richard Gaskin
ambassador at fourthworld.com
Sat Jun 24 12:34:33 EDT 2017
Mark Wieder wrote:
> On 06/24/2017 08:37 AM, Richard Gaskin via use-livecode wrote:
>
>> DoSomething with a and b
>>
>> Two questions:
>>
>> How many of you have never before known that commas are optional
>> between definition arguments?
>
> <hand raised>
>
> However, I don't think that particular syntactic sugar, at least,
> would work. The "and" operator is already in use as a logical anding
> of two parameters, so there's no way for the parser to differentiate
> between that and a list of two separate parameters.
Yeah, just a pipe dream, but a pleasant one.
On the other hand, perhaps a rule could be introduced that any keywords
used in arg strings with no commas when calling a custom handler are
treated as literal text.
We do generally tread lightly with keywords, and often for good reason.
But at the same time the language is chock full o' "sometimes" rules, so
apparently the engine is already smart enough now and then to use a
token different ways depending on context.
For example, like other xTalks LC uses "=" as a comparison operator, but
not for assignments as is commonly done in other languages.
But only sometimes. When used to define a script-local var or constant,
the engine is smart enough to notice the context and allow the readable,
compact form that uses "=" for assignment, e.g.:
constant kWindowMin = 500
local sMaxConnections = 10000
I'm not advocating that the engine team take time away from more
critical tasks (like restoring video playback on Linux soon? <g>) to
monkey with trivialities like comma-free handler params.
It was just odd to find something so fundamental to the language that
I'd never seen before in all my years with LC. And apparently there are
at least two of us.
PS: I tried using the Dictionary to find "and" in order to review any
nuances about its use, but alas was merely reminded why the new Dict
isn't as useful as the old one (beyond the painfully generous white space):
When I run that search I get a great many results, unsorted and
apparently unranked, most not relevant to my search, and with the exact
match hidden somewhere in the bottom third of the results list, which
mystifyingly includes "exit", "export with palette", and
"MCISendString", among others.
Since the old Dictionary was written entirely in LiveCode and the new
one wraps JavaScript inside the browser widget, in a way the funky
results make a very strong statement about the power of LiveCode,
however subtly presented:
On the TIOBE index JavaScript is listed as the world's seventh most
popular language. We're told that one of the reasons languages that
reach the tipping point of the TIOBE Top 50 stay there is because they
have vast ecosystems of good libraries available for common tasks, like
search.
Yet what we see in practice here is that it's easier to write a custom
indexing and search subsystem from scratch in LC than it is to merely
find one of equivalent quality in the JavaScript world.
:)
Vive le LiveCode!
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list