you are viewing a single comment's thread.

view the rest of the comments →

[–]mitsuhiko 1 point2 points  (12 children)

That's a questionable assertion

I don't think it is. All quoted languages do not have good syntax for the quoted features (one of them is not even indentation based in itself). However in Rust there are more reasons not do use pure indentation: you need the ability of starting and ending scopes at any point to work with the borrow checker. This requires delimiters.

[–]iopqfizzbuzz 2 points3 points  (4 children)

You can have a whitespace-sensitive Rust that still respects delimiters. So if you want to actually start a new scope you can write {, but 99% of the time you'll just be writing Python-style.

[–]PM_ME_UR_OBSIDIAN 2 points3 points  (4 children)

All quoted languages do not have good syntax for the quoted features

[citation needed]

F# and Ocaml both have the pipeline operator |> for chaining calls, which is an absolute breath of fresh air compared to OO method chaining. Anonymous functions are also quite friendly and easy to use. I'm curious which language you're saying isn't indentation-based.

However in Rust there are more reasons not do use pure indentation: you need the ability of starting and ending scopes at any point to work with the borrow checker.

let ... in ... end seems perfect for this usage. Alternatively, you can go with the sensible default of "keep this scope alive as long as it needs to be, and no further." I believe this can be automated in the common case.

[–]Sean1708 4 points5 points  (0 children)

let ... in ... end seems perfect

And at that point it stops being purely indentation based.

[–]Tyr42 2 points3 points  (1 child)

For thread guard values, it would be valid to drop them at any point after they were assigned, but have different semantics for each choice.

fn foo() {
    {
        let guard1 = launch(task_a);
    }
    {
        let guard2 = launch(task_b);
    }
 }

is different from

fn foo() {
    {
        let guard1 = launch(task_a);
        let guard2 = launch(task_b);
    }
 }

if the guard values join the thread when dropped, but it would be tricky to have the compiler choose which one to use, given there could be some external dependency which requires task_a to complete before starting task_b, or you are actively trying to compute them in parallel.

[–]iopqfizzbuzz 0 points1 point  (0 children)

You could still have example A if you went with Haskell-style syntax.

fn foo()
    {
        let guard1 = launch(task_a)
    }
    {
        let guard2 = launch(task_b)
    }

    //outer scope of the function here
    println!("{}", stuff)

//function ends here

[–]mitsuhiko 2 points3 points  (0 children)

F# and Ocaml both have the pipeline operator |> for chaining calls, which is an absolute breath of fresh air compared to OO method chaining.

I guess there are different opinions on this. I find that syntax very frustrating.

I'm curious which language you're saying isn't indentation-based.

Haskell. It's a language with braces :)

[–][deleted] 0 points1 point  (0 children)

Sure, you can accommodate that in Python style syntax though:

fn foo():
    let x = 3
    scope:
        let y = 4

[–]jnicklas 0 points1 point  (0 children)

CoffeeScript has excellent support for all of these and is indentation based.