Can when syntax be more concise for when.pogo?

18 views
Skip to first unread message

philip andrew

unread,
Jun 7, 2013, 12:08:26 AM6/7/13
to pogos...@googlegroups.com

Hi there,

In when.pogo

when (x) [
    is 0
      print "x is zero"
    is 1
        print "x is one"
    otherwise
        print "x is not zero or one"
]

Can this be written in a more concise way? I wish to have the condition and statement on the same line.

I tried doing:

when (x) [
    is 0 { print "x is zero" }
...

but no good.

I want to say, I really under-estimated PogoScript when I first saw it, this is a very interesting and slightly amazing language, I'm so so impressed.

Some other thought - have you looked at Scala Macros, maybe you can copy some ideas from the Macro implementation of Scala which is well thought out into PogoScript.

Phil

Tim Macfarlane

unread,
Jun 7, 2013, 5:27:51 AM6/7/13
to philip andrew, pogos...@googlegroups.com
Hi Phil,

You can write:

    when (x) [
        is 0 @{ print "x is zero" }
        ...
    ]

Blocks are written using @{ ... }, otherwise { ... } is a hash.

I am also considering some new syntax for this sort of thing, which will look a bit like this:

    when (x) [
        is 0 -> print "x is zero"
        ...
    ]

The -> would be useful for a one line block. Still a proposed feature so tell me if it's crazy or not.

Haven't looked at Scala Macros yet but will do. I always intended to put macros into the language (and still will) but for the moment I enjoy the fact that you can do a lot without using macros. Lisp was a massive inspiration for this language, so any reason to make it more lispy or more schemy is a good one.

Cheers mate,

Tim.



--
You received this message because you are subscribed to the Google Groups "pogoscript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pogoscript+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages