POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: A test Server Time
4 Nov 2024 17:37:39 EST (-0500)
  Re: A test  
From: Darren New
Date: 21 Sep 2008 10:20:41
Message: <48d65839$1@news.povray.org>
Warp wrote:
>     foo(a, bar(b, c), d, e)
> 
>   If you wrote that as a Haskell-style no-delimiters function call,
> I suppose it would look like:
> 
>     foo a bar b c d e

>   Exactly how does Haskell decide how many parameters 'bar' takes there
> (and consequently how many of the rest of the parameters are for 'foo')?

It's curried. Each function only takes one.

In your example, I'm pretty certain you *have* to have parens.

foo a (bar b c) d e

>   I can't even begin to imagine how you would write that using the
> "point syntax", seen in many examples posted by Andrew. Perhaps you
> use parentheses to enclose the 'bar' call?

Hmmmm. I don't know you can do it with "point syntax" either. I think 
the a . b . c syntax only works when the result of "c" is the one and 
only argument to "b", and the result of "b" is the one and only argument 
to "a".

So if you wanted a function that returns the sum of the lengths of a 
list of strings, you might write
     length . concat
or something, if "concat" was a function that took a list of strings and 
returned their concatenation.

>   There just is something about the Haskell paradigm and syntax that
> makes it confusing and hard to assimilate.

I think most of the powerful languages have syntax that's confusing and 
hard to assimilate. C and C++ are also very confusing in syntax. (For 
example, I can barely follow the reference-counting pointer code you 
posted, and that only because I am only trying to read it and not write 
it. :-)

Even Tcl, which has exactly 12 rules of syntax, winds up being confusing 
to newbies because it's *too* simple. LISP has too many parentheses, 
even tho the grammar is about 3 lines of BNF.

About the only languages that aren't confusing are the weak ones: BASIC, 
Pascal, etc.

If the language is powerful because it does a lot (like Ada or C++) you 
wind up with lots and lots of syntax and lots of rules about the 
interactions. If the language is powerful because it's simple and 
regular (like LISP or FORTH or Tcl or Haskell) then it's confusing 
because there's no *obvious* way to accomplish the powerful stuff you 
know the language is capable of. (Sort of like Go or Chess or something 
- simple rules but very unobvious combinations.)

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.