Лыцарь пичальнава образа - On programming languages' syntax [entries|archive|friends|userinfo]
silly_sad

[ userinfo | ljr userinfo ]
[ archive | journal archive ]

On programming languages' syntax [May. 13th, 2014|01:54 pm]
Previous Entry Add to Memories Tell A Friend Next Entry
Separators are evil.
LinkLeave a comment

Comments:
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 02:57 pm
(Link)
О, а нельзя ли обосновать? (это не значит, что я сомневаюсь, это значит, что я хочу понимать, почему, а заодно прояснить, правильно ли я понимаю слово separator))

Ну и, чтобы два раза не вставать - не знаете ли Вы хороший текст о том, как должен быть в идеале устроен синтаксис ЯП, какие факторы надо учитывать и т.д.?
From:[info]silly_sad
Date:May 13th, 2014 - 03:05 pm
(Link)
lexems/literals/atoms/whatewer are already separated on lower level -- this is why.

is (a, b, c) any better comprehensible than (a b c)

separators add nothing to syntax. they are meaningless.
look:

list ::= .
list ::= member separator list.
list ::= member list.

separator is equivalent to its absence

even WORSE it will be if you attempt to inject some sense into separators (see erlang for example)
in this case they will become a surrogate of parenthesis, and that is really ugly.
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 03:24 pm
(Link)
In lisp-like languages yes.
But even in lisp-like languages, I think, default values and parameter passing by name is good feature. But read parameter passing by name, having no separators, is difficult.
From:[info]silly_sad
Date:May 13th, 2014 - 03:29 pm
(Link)
you mean you need separators to separate sublists within a list...
what i said about parenthesis.....
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 03:51 pm
(Link)
I don't really need them. But it is easier to read
ls(all = true, long = false)
than
ls(all@true long@false)
or something like that.

(ls is function with parameter list as in unix ls command)
From:[info]silly_sad
Date:May 13th, 2014 - 03:54 pm
(Link)
in sql-2.0 similar structure is written as
(book (author person) (issue timestamp))
or
(foo (all true) (long false))
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 04:12 pm
(Link)
Parameter binding and function invokation are different ideas and I want to see difference on syntactic level. Your syntax makes sense, if we will use other square or curly brackets... but number of bracket forms is small ("()","{}","{}").
Or, maybe, we can use
(foo @(all true) @(long false))... Yes, makes sense.
From:[info]silly_sad
Date:May 13th, 2014 - 04:21 pm
(Link)
no: (foo @(all true) @(long false))
yes: (foo (@ all true) (@ long false))

@ -- operator of parameter binding, at first glance.

you can even think of it as a slightly perverted set-comprehension

(foo (= all true) (= long false))

where all members subsequent to "foo" constitute a predicate and are implicitly connected by "AND"

also there is no harm in allowing operator to appear at second position in any invocation (as well as in the first position)
From:[info]silly_sad
Date:May 13th, 2014 - 04:23 pm
(Link)
IF !!!
you have an "operator" term as opposed to "name" term

it is controversial, but i think it is a good idea, at least it is good for readability.
From:[info]silly_sad
Date:May 13th, 2014 - 03:15 pm
(Link)
also they add some pain while during machine writing:
say we want to compose a list written as a string:

a := ""
a := a ++ "," ++ Item

we got: ",1,2,3" which is a syntax error

a := ""
a := Item ++ "," ++ a

we got: "1,2,3," which is a syntax error again

and everybody see that this "error" is not en error, any compiler could swallow easily -- yet it is out of _HUMAN_ idea of separators.

so that separators MAKE ANY LIST NON-HOMOGENOUS -- tail element is exceptional.

imagine how many lines of code in this world dedicated to the only purpose to serve this exception.
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 03:27 pm
(Link)
Yes, but it is easy to fix by 1 function (it can be inline or macros).
From:[info]silly_sad
Date:May 13th, 2014 - 03:28 pm
(Link)
"TO FIX"????
we are definitely unclear here.
you either have to think, or you are beyond hope
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 03:39 pm
(Link)
a := ""
a := my_join(a,Item,",");

my_join(word,suffix) :=
if (word == "")
suffix
else if suffix == ""
word
else word ++ separator ++ suffix;
From:[info]silly_sad
Date:May 13th, 2014 - 03:51 pm
(Link)
listen to yourself!

-- no! no! it is not broken!!! we can fix it!!!
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 03:53 pm
(Link)
no-no-no!
It is really broken (I've said "yes"), but it is easy to fix one time and forever.
From:[info]silly_sad
Date:May 13th, 2014 - 03:56 pm
(Link)
ok. it is broken.
are u going to create yet another broken lang?
From:[info]os80.livejournal.com
Date:May 13th, 2014 - 03:47 pm
(Link)
Excuse me... I've lost one parameter in description of my_join()

a := ""
a := my_join(a,Item,",");

my_join(word,suffix,separator) :=
if (word == "")
suffix
else if suffix == ""
word
else word ++ separator ++ suffix;
From:[info]silly_sad
Date:May 13th, 2014 - 03:16 pm
(Link)
r we clear now?
From:[info]silly_sad
Date:May 13th, 2014 - 03:27 pm
(Link)
vse horoshie teksty tut:
file.bestmx.net/ee/articles

ideal syntax is slightly approached in /ee/articles/SQL-2.0/*

also a simpler case -- a data serialization language with ideal syntax is located in /ee/software/urt