dg icon indicating copy to clipboard operation
dg copied to clipboard

Indented blocks should work for kwargs as well

Open notpushkin opened this issue 9 years ago • 3 comments

<...> If there was no operator, however, each line is an argument to the last function call.

print "Doge says:" sep: "\n"
    "not want talk"
    "finally sleep"

I expected something like that to work, too:

language_info = dict'
    name: "dg"
    version: get_distribution "dg" |>.version
    mimetype: "text/x-dg"
    file_extension: ".dg"

But it doesn't.

    ...
    File "/home/ale/dev/dg_kernel/dg_kernel/kernel.dg", line 13
    version: get_distribution "dg" |>.version
           ^
dg.SyntaxError: keyword argument to what function?

sigh

notpushkin avatar Sep 02 '16 13:09 notpushkin

It does work with keyword arguments. Your example doesn't work because a: b |>.c is (a: b).c. (Which, I guess, makes passing keyword arguments on separate lines not particularly useful...)

pyos avatar Sep 02 '16 19:09 pyos

Oh. dg.STRENGTH !! ":" = (210, 10) helped, although not sure it won't break something else.

notpushkin avatar Sep 02 '16 20:09 notpushkin

In the function call context, it won't. The empty operator has a right binding strength of 190, which was also the original right binding strength of :, so there was no operator R such that a b : c R d parsed as a ((b : c) R d) -- if an operator was strong enough to bind with 's RHS, it was also strong enough to bind with:'s.

However, : is also used in function definitions to declare default argument values. Your tweak will make functions with all arguments optional, i.e. a: b ... -> ..., parse as a: (b ... -> ...).

pyos avatar Sep 02 '16 21:09 pyos