Some syntax review

10 views
Skip to first unread message

Аркадий Рост

unread,
Nov 11, 2009, 8:06:52 AM11/11/09
to golang-nuts
Well, in general Go language looks pretty good, but I'm a bit
disappointed with function declarations. In fact, I think functions
syntaxes is not as good as it ought to be.

I expected something like this:

func say (who string, what string) -> (string)
{
return who+what;
}

or

func greet (what string) -> ()
{
ftm.Println(what);
}

I think that this syntaxe for function declarations is much simple and
easy to use.

Dmitry Chestnykh

unread,
Nov 11, 2009, 8:44:44 AM11/11/09
to golang-nuts
> func say (who string, what string) -> (string)

Why type extra characters when you can avoid them? :-)

- Dmitry

Аркадий Рост

unread,
Nov 11, 2009, 8:59:39 AM11/11/09
to golang-nuts


On 11 ноя, 16:44, Dmitry Chestnykh <dmi...@codingrobots.com> wrote:
> > func say (who string, what string) ->  (string)
>
> Why type extra characters when you can avoid them? :-)
>

Well, it's not very difficult, but makes code more obvious so I think
it worse it. If some one don't want type exra characters they may be
implemented as syntax sygar.
> - Dmitry

Daniël de Kok

unread,
Nov 11, 2009, 9:11:34 AM11/11/09
to Dmitry Chestnykh, golang-nuts
On Nov 11, 2009, at 2:44 PM, Dmitry Chestnykh wrote:
>> func say (who string, what string) -> (string)
>
> Why type extra characters when you can avoid them? :-)

A lot of syntactic sugar is unnecessary if readability is not a goal ;). Separating parameters and return values with some sugar makes signatures a easier to read (for me, at least).

Take care,
Daniel de Kok

Dmitry Chestnykh

unread,
Nov 11, 2009, 9:17:29 AM11/11/09
to golang-nuts
> A lot of syntactic sugar is unnecessary if readability is not a goal ;). Separating parameters and return values with some sugar makes signatures a easier to read (for me, at least).

Agree, but I think ")" is okay as a separator :)

Also, Go already has <- operator that has a different meaning than the
proposed ->.

- Dmitry

Dmitry Chestnykh

unread,
Nov 11, 2009, 9:18:41 AM11/11/09
to golang-nuts
> Well, it's not very difficult, but makes code more obvious so I think
> it worse it. If some one don't want type exra characters they may be
> implemented as syntax sygar.

Here you go:

func say (who string, what string) /* -> */  string

:-)

-Dmitry

Аркадий Рост

unread,
Nov 11, 2009, 9:44:16 AM11/11/09
to golang-nuts
I don't thinkthat ")" is a really good separator(for example, for
multiple return values).For me it will be better to use ->.

Trevor Strohman

unread,
Nov 11, 2009, 11:37:33 AM11/11/09
to golang-nuts
If you want to highlight return types, tell your editor to color them
differently. I find that Go is much easier to read with syntax
highlighting on.
Reply all
Reply to author
Forward
0 new messages