At 2002-05-30 02:26, Jon Fairbairn wrote:
I think this is extremely bad language design! In general I like having layout rules, but ...
What's the deal with the whole "layout" thing anyway? I've never come across it before in another language. Is it an academic thing? It drove me nuts when I first started Haskell, until I discovered you could use semicolons/braces instead (which I always do). If I were teaching Haskell to "working programmer" types like myself, I would encourage them to always use full semicolons and braces and forget layout entirely (except a lot of available Haskell source seems to use it). Certainly I find {;} more readable, and I suspect anyone else with a C/C++/Java background (or even a Scheme/Lisp background) does too.</RANT> -- Ashley Yakeley, Seattle WA
Ashley Yakeley wrote:
At 2002-05-30 02:26, Jon Fairbairn wrote:
I think this is extremely bad language design! In general I like having layout rules, but ...
What's the deal with the whole "layout" thing anyway? I've never come across it before in another language. Is it an academic thing?
How about FORTRAN (to a very small extent) or Python? I used to dislike layout, but I must say that it didn't take long to become a supporter once you start using it. If you look at C (& offspring), it's not the {;} that makes the code readable, it's the indentation that does. So why not acknowledge that? -- Lennart
If you look at C (& offspring), it's not the {;} that makes the code readable, it's the indentation that does. So why not acknowledge that?
Redundancy maybe? What's wrong in having both layout and punctuation? For instance, then you can have an emacs mode that handles the layout given the punctuation. I used to believe in layout, but got converted the other way round. We used Scala, a new functional/object oriented language we design, in a course with 100+ students. Scala used to have layout rules somewhat like Haskell's. In our experience it was the single thing that confused students most. Problems were: (1) Students did not properly indent their code. (2) Students used editors that disagreed in the handling of tabs. (3) Students wrote multi-line statements that started at the same column. I came away with with the learning experience that a little redundancy in the syntax is a good thing. Cheers -- Martin
Martin Odersky <martin.odersky@epfl.ch> writes:
Redundancy maybe? What's wrong in having both layout and punctuation?
Short answer: What's wrong with it is that humans use layout to infer the semantic meaning, compilers use punctuation. Thus it's not really redundancy. -kzm -- If I haven't seen further, it is by standing in the footprints of giants
... layout rules somewhat like Haskell's. In our experience it was the single thing that confused students most.
same here, for exactly these reasons. students get really confused. on the other hand, students regularily get confused by other things as well, like homework assignments on formal languages, so that alone is not enough reason to drop the subject altogether :-) -- -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ -- -- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/252 --
On Thu, 30 May 2002, Ashley Yakeley wrote:
it). Certainly I find {;} more readable, and I suspect anyone else with a C/C++/Java background (or even a Scheme/Lisp background) does too.</RANT>
Just a data point: I learned Basic, Pascal, Standard ML, C, Haskell, C++, Perl, Python in that order and actively use Haskell, C++, Perl & Python at the moment, and I find the `visual noise' of braces and semi-colons in C++ and Perl to be very irritating when, as Lennart points out, to be readable by me my code has to embody these structures by layout. (It's primarily the noise of all those `fun', `val' and `end's rather than deeper language issues that put me off looking at ML again.) Indeed, I (half) there ought to be a warning on the main page of Haskell.org saying `WARNING: Using Haskell can lead to semi-colon blindness' since I relatively frequently spend ten minutes trying to figure out why C++ code isn't compiling only to realise that, whilst indented structurally the semi-colons are missing :-S I suspect using layout rule is forever destined to be controversial... ___cheers,_dave_________________________________________________________ www.cs.bris.ac.uk/~tweed/ | `It's no good going home to practise email:tweed@cs.bris.ac.uk | a Special Outdoor Song which Has To Be work tel:(0117) 954-5250 | Sung In The Snow' -- Winnie the Pooh
What's the deal with the whole "layout" thing anyway? I've never come across it before in another language.
Python has it as well (they stole it from Haskell?)
If I were teaching Haskell to "working programmer" types like myself, I would encourage them to always use full semicolons and braces ...
while we're at it - what's the deal with type inference? sometimes I think it is *really bad* language design if the program may contain untyped declarations of identifiers. ghc -Wall warns nicely about undeclared top-level types but what about locals? I've never came across a language that would allow them declared untyped. of course I know (some of) the `academic' background (type inference, type checking) but what about it from a software engineering point of view? \end{rant} .. I think neither the layout rule nor type inferencing are likely to disappear from Haskell .. -- -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ -- -- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/252 --
G'day all. On Thu, May 30, 2002 at 01:10:03PM +0200, Johannes Waldmann wrote:
Python has it as well (they stole it from Haskell?)
Python's layout rule looks more like Occam's than Haskell's, to my eyes. Aside: Was Occam the first language of the post-punched-card era to use layout as syntax?
while we're at it - what's the deal with type inference?
sometimes I think it is *really bad* language design if the program may contain untyped declarations of identifiers.
Presumably you're not suggesting requiring type declarations in every pattern match too? I think it's something to do with where you draw the line. You could theoretically require type declarations: - Nowhere, unless the type inference mechanism can't cope with it. - Module interfaces. - Top-level declarations. - "where" clauses too. - "let" - Everywhere that a variable could be defined, including case-expressions, list comprehension generators and lambdas. - Every subexpression. I personally think it's wrong not to require explicit type declarations for everything exported from a module for engineering reasons. Sane separate compilation is important, IMO. Cheers, Andrew Bromage
Hi All, Andrew J Bromage wrote:
G'day all.
On Thu, May 30, 2002 at 01:10:03PM +0200, Johannes Waldmann wrote:
Python has it as well (they stole it from Haskell?)
Python's layout rule looks more like Occam's than Haskell's, to my eyes.
Aside: Was Occam the first language of the post-punched-card era to use layout as syntax?
I fuzzily recall that SICStus Prolog silently tolerated omissions of commas and dots, allowing for: p(X) :- g(X,Y) h(Y) p(X) g(Y,Z) :- ... But Haskell already existed at this point. Alexander
participants (8)
-
Alexander V. Voinov -
Andrew J Bromage -
Ashley Yakeley -
D. Tweed -
Johannes Waldmann -
ketil@ii.uib.no -
Lennart Augustsson -
Martin Odersky