Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 4725 days ago | link | parent

via http://arclanguage.org/item?id=16807


2 points by Pauan 4724 days ago | link

Thanks. Though I'm still trying to pin down the "right" meaning for ":" and ";"

For instance, I've actually changed it since then. I should update that page to describe the new changes.

-----

2 points by iopq 4711 days ago | link

What is the change? I hate parens in any language with a passion. I even suggested a similar approach to Newspeak (a language based on Smalltalk): https://groups.google.com/forum/?hl=en&fromgroups=#!topi...

of course here you can get away with just positional placement because all binary and keyword sends make it fairly clear where the message send is and where the argument is

-----

1 point by Pauan 4710 days ago | link

Let's see... it's been a while, so I'm looking at the Nulan source code... Ah, right. Here's the latest rules:

  : creates a new list that continues until either ; or ( or ) is encountered
  ; creates a new list that continues until either ; or ) is encountered
So for instance:

  foo: bar: qux; corge -> (foo (bar (qux)) (corge))
  foo: bar; qux; corge -> (foo (bar) (qux) (corge))
  foo: bar: qux: corge -> (foo (bar (qux (corge))))
  foo: bar (qux corge) -> (foo (bar) (qux corge))
The differences are:

  : now terminates on (

  ; creates a new list in addition to terminating all previous : and ;
     (before, it only terminated and didn't create a new list)

  ; now terminates ; in addition to :

-----

1 point by Pauan 4710 days ago | link

I've actually changed my mind so that I don't mind using parens, but only for function calls. Calls to a vau (def, if, and, let, etc.) shouldn't be wrapped in parens:

   mac accessor -> n v
     uniqs %a
       {def n -> %a
         {{%a v} %a}}

   def or: casevau env
     x    -> (eval x)
     x @r -> let x (eval x)
               if x x (eval {or @r})
The above is a hypothetical mockup for new syntax for Nulan. It's radically different than the current syntax, but I think it looks very clean. At least, compared to the current syntax:

  $mac accessor; N V ->
    $uniqs %A
      [$def N; %A ->
        [[%A V] %A]]

  $defvau $or Env
    X    -> eval X
    X @R -> $let X: eval X
              $if X X: eval [$or @R]

-----

3 points by iopq 4710 days ago | link

why would you need two different characters?

foo; bar; qux ;corge (foo(bar(qux))corge

foo; something is foo(something)

something ;foo is something(foo)

-----

2 points by Pauan 4709 days ago | link

Oh, I see what you're saying. You're saying ";" should have different meaning depending on whether it's to the left or the right of the symbol. That could work, but I feel it's making whitespace a bit too significant. No way to know for sure without trying it out, though.

-----

2 points by iopq 4707 days ago | link

well, you already make whitespace significant by saying that alphabeta is not alpha beta

the real crux of the issue is whether it comes before an identifier or after don't think of it as whitespace disambiguating nobody says *pointer in C is "too significant whitespace" just because it can't be separated by a space (in which case it becomes multiply!)

-----

1 point by Pauan 4706 days ago | link

Like I said, I think it's only a bit too far, so if somebody wants to run with that idea, go for it. I personally favor the idea of having multiple syntaxes that parse to the same AST.

-----

1 point by akkartik 4707 days ago | link

I didn't know you couldn't have a space after deref!

But, I dunno.. attaching ';' to identifiers is different from attaching '*'. Our brains are trained to treat the semi-colon as punctuation, never part of a word. Even programming languages have only reinforced this pattern. It's going to be a hard habit to break.

-----

2 points by rocketnia 4706 days ago | link

"Our brains are trained to treat the semi-colon as punctuation, never part of a word. Even programming languages have only reinforced this pattern. It's going to be a hard habit to break."

Give it 100 years. ;)

-----

1 point by Pauan 4706 days ago | link

I'm assuming ";" was just an example... I would personally use ":" rather than ";" if I used only one character.

-----

3 points by iopq 4705 days ago | link

I would personally use something like | if it's not used for anything

it looks like an undirected paren so in cases like a |b| c it translates to a ((b) c) or (a (b)) c I guess I'd pick the first option (more natural for reading left to right), but for the order of operations it doesn't matter

-----

2 points by akkartik 4705 days ago | link

I like this! It seems the semi-colons were blinding me to the possibilities :)

-----

1 point by akkartik 4709 days ago | link

I agree that this is probably too much. Modern languages are training us to ignore the semi-colons; to have to pay attention to the whitespace around them seems retrogressive.

-----

1 point by Pauan 4709 days ago | link

To be fair, the semicolons in Nulan are mostly used as infix operators, unlike in languages like C where they're required at the end of every statement. And Nulan already uses significant whitespace indentation. So I don't think it'd be a lot worse to make the whitespace significant for ":" or ";" I just think it might be a bit too far.

-----

1 point by Pauan 4710 days ago | link

Because there are situations where you want to terminate things, like with "and" and "or":

  and: foo 1; bar 2; qux 3 -> (and (foo 1) (bar 2) (qux 3))
Keep in mind my system was intentionally designed to get rid of as many parentheses as possible in as many situations as possible.

Now that I'm more lenient toward parens, I'll probably simplify ":" and get rid of ";"

---

There is one other situation where I use ";" in Nulan: functions that continue on the next line:

  $def foo; X Y ->
    ...
But with my new syntax for functions, I can get rid of that:

  def foo -> x y
    ...

-----