POV-Ray : Newsgroups : povray.off-topic : Ocaml Server Time
4 Sep 2024 15:20:58 EDT (-0400)
  Ocaml (Message 8 to 17 of 17)  
<<< Previous 7 Messages Goto Initial 10 Messages
From: Darren New
Subject: Re: Ocaml
Date: 5 Feb 2010 14:54:52
Message: <4b6c778c$1@news.povray.org>
Invisible wrote:
>   integer * string
> which seems a rather perverse choice. 

Cartesian product of integers and strings.  I'm not sure what a "sum type" 
would be.

> instead of "(True, 5)"? It would be clearer...)

Wait till you get to python, where the tuple constructor is actually the 
comma, the parens are optional, and you try to figure out how to write a 
one-element tuple literal, or the empty tuple.

> Haskell makes the rather illogical choice of using "--" as the start 
> marker for a comment. 

Common in a lot of other languages like SQL and Ada. FWIW.

> Ocaml uses the even stranger choice of "(* ... *)". 

Which is Pascal for comments, if your keyboard (punched cards) don't have 
curly braces. FWIW.

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: Orchid XP v8
Subject: Re: Ocaml
Date: 5 Feb 2010 16:35:48
Message: <4b6c8f34$1@news.povray.org>
>>   integer * string
>> which seems a rather perverse choice. 
> 
> Cartesian product of integers and strings.  I'm not sure what a "sum 
> type" would be.

Either Int String

is a sum type. The set of possible values is the *sum of* the set of 
possible Int values and the set of possible String values.

Whereas... well, you understand what a Cartesian product is already, right?

Haskell's "algebraic data types" are sum types of product types. (The 
sum may contain only one summand, but a sum none the less. Actually, if 
you enable the EmptyDataDecls extension, zero summands are permissible...)

>> instead of "(True, 5)"? It would be clearer...)
> 
> Wait till you get to python, where the tuple constructor is actually the 
> comma, the parens are optional, and you try to figure out how to write a 
> one-element tuple literal, or the empty tuple.

Oh, the *type constructor* for a 2-tuple is "(,)", and for a 3-tuple 
it's "(,,)".

So if you want to be 73% anal, you can write "(,) String Integer" 
instead of "(String,Integer)". :-}

Off the top of my head, I don't *believe* this works with value 
constructors... No, wait. I'm wrong; it does work.

   (,,) :: a -> b -> c -> (a,b,c)

This means we can write

   zip = zipWith (,)

Eat THAT and smoke it! o_O

(Similarly, "[Char]" can also be written "[] Char".)

>> Haskell makes the rather illogical choice of using "--" as the start 
>> marker for a comment. 
> 
> Common in a lot of other languages like SQL and Ada. FWIW.

I know Eiffel uses it. But then, Eiffel is weird.

>> Ocaml uses the even stranger choice of "(* ... *)". 
> 
> Which is Pascal for comments, if your keyboard (punched cards) don't 
> have curly braces. FWIW.

...more useless information to add to my collection! o_O

Then again, in Pascal "(*)" is not a meaningful thing to write in the 
first place. ;-)

PS. I'm loving the way Haskell uses curly brackets for explicit 
grouping, AND ALSO for named-field syntax. Way to use the exact same 
symbol for two unrelated things that you might want to do AT THE SAME TIME!

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Ocaml
Date: 5 Feb 2010 17:21:06
Message: <4b6c99d2$1@news.povray.org>
Orchid XP v8 wrote:
> Either Int String

Obvious once stated.

> Oh, the *type constructor* for a 2-tuple is "(,)", and for a 3-tuple 
> it's "(,,)".

Not in Python. The cosntructor for a 2-tuple is ,
No parens needed. Figure *that* one out. :-)

>> Common in a lot of other languages like SQL and Ada. FWIW.
> I know Eiffel uses it. But then, Eiffel is weird.

That too. All the "readable" languages tend to use it, because it's how you 
offset comments in English -- that is, if you have a comment to make.

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: Kevin Wampler
Subject: Re: Ocaml
Date: 5 Feb 2010 17:27:56
Message: <4b6c9b6c$1@news.povray.org>
Darren New wrote:
> Not in Python. The cosntructor for a 2-tuple is ,
> No parens needed. Figure *that* one out. :-)

This isn't *quite* correct, since a single comma can construct either a 
1-tuple or a 2-tuple depending on how it's used:

"foo", --> 1-tuple
"foo",bar --> 2-tuple

It's probably best to view the tuple constructor as a comma, which can 
be used as a binary operator or as a unary postfix operator (ignoring 
3-n-tuples of course).


Post a reply to this message

From: Darren New
Subject: Re: Ocaml
Date: 5 Feb 2010 21:18:28
Message: <4b6cd174@news.povray.org>
Kevin Wampler wrote:
> This isn't *quite* correct, since a single comma can construct either a 
> 1-tuple or a 2-tuple depending on how it's used:

Right. That's the weirdness of it, including the fact that there are other 
uses for the comma (like between function arguments) as well.

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: Kevin Wampler
Subject: Re: Ocaml
Date: 5 Feb 2010 22:36:43
Message: <4b6ce3cb$1@news.povray.org>
Darren New wrote:
> Kevin Wampler wrote:
>> This isn't *quite* correct, since a single comma can construct either 
>> a 1-tuple or a 2-tuple depending on how it's used:
> 
> Right. That's the weirdness of it, including the fact that there are 
> other uses for the comma (like between function arguments) as well.


This seems to be (for better or worse) sort of the python philosophy of 
language design, and as far as I can tell they at least seem to be 
consistent about when they are inconsistent.  It reminds me of how they 
parse expressions with comparison operators specially so you can type 
"if a < b < c:" and have it work.  It's simple to understand on a 
"human" level, but it's definitely a special case in how the syntax is 
parsed.


Post a reply to this message

From: Darren New
Subject: Re: Ocaml
Date: 5 Feb 2010 22:44:51
Message: <4b6ce5b3$1@news.povray.org>
Kevin Wampler wrote:
> "if a < b < c:" and have it work.

Yeah. I really don't understand why more languages don't support this sort 
of thing. I mean, even COBOL got *that* right. :-)

> It's simple to understand on a 
> "human" level, but it's definitely a special case in how the syntax is 
> parsed.

Yeah, it's just weird to see an expression like
    x = y,



-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

From: Orchid XP v8
Subject: Re: Ocaml
Date: 6 Feb 2010 03:32:42
Message: <4b6d292a@news.povray.org>
Darren New wrote:
> Kevin Wampler wrote:
>> "if a < b < c:" and have it work.
> 
> Yeah. I really don't understand why more languages don't support this 
> sort of thing. I mean, even COBOL got *that* right. :-)

BUUUURN!

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Orchid XP v8
Subject: Re: Ocaml
Date: 6 Feb 2010 03:34:48
Message: <4b6d29a8$1@news.povray.org>
>>> Common in a lot of other languages like SQL and Ada. FWIW.
>> I know Eiffel uses it. But then, Eiffel is weird.
> 
> That too. All the "readable" languages tend to use it, because it's how 
> you offset comments in English -- that is, if you have a comment to make.

TeX uses "--" to mean an N-dash, and "---" to mean an M-dash [which is 
the kind that ought to be used for seperating a comment].

Haskell being what it is, you can *probably* activate Unicode mode and 
use the actual Unicode character for an M-dash.

(I don't know if you know this, but Haskell can actually be written with 
Unicode symbols like arrays and stuff in place of the cheese ASCII-art 
everybody always uses...)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Ocaml
Date: 6 Feb 2010 11:13:08
Message: <4b6d9514@news.povray.org>
Orchid XP v8 wrote:
> (I don't know if you know this, but Haskell can actually be written with 
> Unicode symbols like arrays and stuff in place of the cheese ASCII-art 
> everybody always uses...)

And I'm pretty sure APL has its own block of characters in unicode as well.

-- 
Darren New, San Diego CA, USA (PST)
   Forget "focus follows mouse." When do
   I get "focus follows gaze"?


Post a reply to this message

<<< Previous 7 Messages Goto Initial 10 Messages

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