4 ms·
I'm somewhat confused by the indentation rules. Is this code valid? fun abc(d): d+1 end
by rogerbinns 10y ago
I'm somewhat confused by the indentation rules. Is this code valid?
fun abc(d):
d+1
end
- jswrenn 10y agoYes, Pyret is totally indentation-insensitive.
- skrishnamurthi 10y agoFOR NOW. We have a plan for making the indentation checked but it's not been our top priority, but it is on our stack. Languages take a while to cook. Welcome to the kitchen. (-:
- rogerbinns 10y agoI must admit to being a fan of the python approach. My example code above is obviously "wrong", and is immediately so in Python. In other languages it is valid, and then brings a burden for a reader of trying to determine why the indentation doesn't match the intent. Since code is read a lot more than it is written, that seems like pointless complications for no real benefit.
- skrishnamurthi 10y agoYou're conflating two things. Indentation can be enforced without being semantic. In Python, indentation is semantic: if you move certain statements two lines out, you've changed the meaning of the program. In Pyret, our goal is to enforce indentation but never make it semantic: i.e., there's an unambiguous place for every bit of code. You can select-all and hit Tab in the Pyret editor and it'll reindent your whole program according to the rules. We just haven't yet implemented the checker for these rules (in part because we still don't all agree on exactly what they will be). Once we agree, the program you wrote would be a syntax error, but a user could have the system automatically indent it for them to make it right. (Even now, they can have the line be automatically indented for them.)