POV-Ray : Newsgroups : povray.off-topic : How does Haskell work? : Re: How does Haskell work? Server Time
4 Sep 2024 09:21:03 EDT (-0400)
  Re: How does Haskell work?  
From: Darren New
Date: 17 Mar 2010 10:52:34
Message: <4ba0ecb2$1@news.povray.org>
Invisible wrote:
> written in an OO language can create variables, read/write them, take 
> conditional branches (if/then/else, for, while, etc.) and invoke 
> methods. (Object creation can be regarded as a special case of a method 
> call. Indeed, in some languages it *is* a method call.)

And in Smalltalk, conditional branches are also method calls. You send two 
"blocks" to a boolean, and it executes the appropriate one.  E.g., you call

(x == 5) ifTrue: [y print] ifFalse: [z print]

So (x == 5) sends the == message to x with the argument 5, and that returns 
either true or false.  The methos "ifTrue:ifFalse:" in "true" evaluates and 
returns the first argument. The method of the name in "false" evaluates and 
returns the second argument.  So, technically, you don't need conditionals 
either, just deferred evaluation (aka lambda expressions).

> Other languages have records. A few other languages have true 
> enumerations. But Haskell has ADTs, which are a weird hybrid of the two. 
> The only other langruage I can think of that approaches this is C with 
> its "union" construct.

Ada and Hermes and heh. Heck even Visual Basic has such as "variant" type. I 
think Pascal has the same thing too.



That's pretty cool, tho.  I love languages where a very simple idea is taken 
to extremes.

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

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