POV-Ray : Newsgroups : povray.off-topic : A Haskell question... Server Time
11 Oct 2024 01:23:53 EDT (-0400)
  A Haskell question... (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Orchid XP v7
Subject: Re: A Haskell question...
Date: 4 Feb 2008 16:47:24
Message: <47a787ec$1@news.povray.org>
>>>   Doesn't Haskell support encapsulation?
> 
>> Last time I checked, Java has the same limitation.
> 
>   You said:
> 
>>> struct Point {int x; int y;}
>>    data Point = Point {x, y :: Int}
>>
>> Caution: Note that the names "x" and "y" must be unique within the
>> entire module. For this reason, you'd probably use longer names.
> 
>   I understand to mean that the names 'x' and 'y' in your code above
> actually garbage the global namespace.

No - the namespace of the current module. And in Java it would be the 
same - the names are local to this class file.

>   In the original C code they are local to 'Point' and do not affect
> anything outside it.

That's true...

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


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: A Haskell question...
Date: 4 Feb 2008 16:50:11
Message: <47a78893@news.povray.org>

> No - the namespace of the current module. And in Java it would be the 
> same - the names are local to this class file.

No. In Java it's local to the class, not to the file. You can have 
multiple classes in a single source file, as long as only one of them is 
public.


Post a reply to this message

From: Orchid XP v7
Subject: Re: A Haskell question...
Date: 4 Feb 2008 16:53:35
Message: <47a7895f$1@news.povray.org>
Nicolas Alvarez wrote:

>> No - the namespace of the current module. And in Java it would be the 
>> same - the names are local to this class file.
> 
> No. In Java it's local to the class, not to the file. You can have 
> multiple classes in a single source file, as long as only one of them is 
> public.

Really? Interesting... I wasn't aware Java had non-public classes. 
(Although I did wonder why the hell you have to write "public" at the 
start of every class.)

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


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: A Haskell question...
Date: 4 Feb 2008 17:06:01
Message: <47a78c49$1@news.povray.org>

> Really? Interesting... I wasn't aware Java had non-public classes. 
> (Although I did wonder why the hell you have to write "public" at the 
> start of every class.)

If you don't add 'public', the class is only accessible from other 
classes on the same package.


Post a reply to this message

From: Orchid XP v7
Subject: Re: A Haskell question...
Date: 4 Feb 2008 17:08:21
Message: <47a78cd5$1@news.povray.org>
Nicolas Alvarez wrote:

>> Really? Interesting... I wasn't aware Java had non-public classes. 
>> (Although I did wonder why the hell you have to write "public" at the 
>> start of every class.)
> 
> If you don't add 'public', the class is only accessible from other 
> classes on the same package.

Well, I didn't know that.

Interesting - once or twice a year that might be useful...

So much for university education, eh? Mind you, we learned Java from the 
guy who tried to tell us that the maximum range of a "double" is "more 
than the number of atoms in the universe". ;-)

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


Post a reply to this message

From: Michael Zier
Subject: Re: A Haskell question...
Date: 5 Feb 2008 01:59:18
Message: <47a80946$1@news.povray.org>
Am Mon, 04 Feb 2008 15:28:46 +0000 schrieb Invisible:

> 
> Each Java class has to go into a separate source code file. Each Haskell

Oh, then I have to throw away my Java compiler, because I usually write 
all the classes I need for my (admittedly small) mobile phone projects 
into one file. And it compiles! Bad compiler! 

Ok, it's not good for reusability, I know that...


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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