Skip to content

One-line blocks #7

@hazer-hazer

Description

@hazer-hazer

Having only {} for control-flow structures' bodies as Rust and Swift does is consistent, anyway, I have a more liberal (and maybe narrow) view on Jacy, and would like to see things like one-liners, etc.
In very old versions of Jacy, when it was absolutely anything but not what it is planned to be now, there was an idea that is really strange and kind of stupid -- using => for one-line blocks. I don't think I need to explain why this is a bad idea.

Proposal

: sounds pretty good, the only problem I see is confusing with indentation-dependent programming languages like Python and Nim. Also, else: haunts me, as it is more consistent to have it but it is absolutely useless from the view of a user and parsing.
Anyway, here it is and is likely to exist after the first version.

Why?

🤔 IDK.
I think it would fit nicely with optional semicolons that will come after the first version.
Let's look at examples:

let something = if anotherThing { value } else { None };

// Becomes
let something  = if anotherThing: value else: None;

Pretty clean, but:

if something: doSomething()
else: meow();

requires ; at the end, thus this proposal must be reviewed after semicolons optionality will be implemented.

Appendix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions