News for hackers. Stuff that matters.
Re:Language Design: Use 'ident: Type' not 'Type ident' by WalterBright on Friday May 01, 2020 @08:22PM (#23047871)
To declare two pointers to int in C:

    int *a, *b;
In D:

    int* a, b;
The use of whitespace makes the distinction clear, although the parser doesn't care.
Re:Language Design: Use 'ident: Type' not 'Type ident' by klyrs on Friday May 01, 2020 @08:40PM (#23048007)
C is just riddled with mistakes and this one finally gelled with me. Python taught me that whitespace is great for syntax and, in this case, I'm quite convinced that it should be used more firmly in most languages.
Re:Language Design: Use 'ident: Type' not 'Type ident' by andreareina on Saturday May 02, 2020 @01:10AM (#23049417)
Python's syntax precludes works against a lot of things, like first-class lambdas, case (yes it can be emulated with if/elif, but it's not the same, even without fallthrough), pattern-matching in general, or assigning the result of a method-chaining pipeline to a variable.

I use python at $dayjob, and I run into the limitations of whitespace as syntax all the time.

Re:Language Design: Use 'ident: Type' not 'Type ident' by klyrs on Saturday May 02, 2020 @12:39PM (#23052899)
Yeah, the switch thing is a mindboggle, but the associated pep makes it very clear that/why the problem is quite unsolvable.

https://www.python.org/dev/peps/pep-3103/

It's quite frustrating as there are a lot of situations where a simple switch would be so nice...

Re:Language Design: Use 'ident: Type' not 'Type ident' by dirtydroog on Friday May 01, 2020 @09:53PM (#23048396)
I find the opposite, I can't stand it. Give me curly braces over arbitrary indentation any day.
Re:Language Design: Use 'ident: Type' not 'Type ident' by mhh__ on Friday May 01, 2020 @10:33PM (#23048622)
I think a better (subjective of course) lesson might be to enforce a style.

I have been thinking about making a toy compiler (I wanted to write a borrow checker) that treats bad code as an error, solely aimed at numerical code - I have recently had "Scientific Programming in Python for physics etc." inflicted on me.

Slight tangent, but I think if Haskell enforced some kind of whitespace a la Python it would be much more approachable in real codebases (Haskell is usually quite readable if you are just translating mathematics into code but it - to me at least - feels dreadful as a productive language because of the way a lot of functions seem to be dumped onto into the text editor in a lot of the code I have read)

Re:Language Design: Use 'ident: Type' not 'Type ident' by iso-8859-1 on Saturday May 02, 2020 @12:24AM (#23049181)
What do you mean? Whitespace does mean something in Haskell, see http://echo.rsmw.net/n00bfaq.html .
Re:Language Design: Use 'ident: Type' not 'Type ident' by dllthomas on Saturday May 02, 2020 @04:33PM (#23054690)
Not really relevant to the broader discussion, but Haskell's whitespace sensitivity is defined in terms of automatic insertion of braces and semicolons, and you can write it that way instead if you want. A few people do write Haskell that way (SPJ maybe?) but the community is mostly united around using whitespace. That said, it's useful to know about the braces and semicolons if you're generating Haskell code, because that's often easier. Also occasionally at the GHCI prompt, where it will let you keep things on one line.
Re:Language Design: Use 'ident: Type' not 'Type ident' by todd8 on Saturday May 02, 2020 @06:27AM (#23050829)
As in Python, whitespace in the form of indentation matters in Haskell.