POV-Ray : Newsgroups : povray.off-topic : Innovative open source? Server Time
9 Oct 2024 12:18:21 EDT (-0400)
  Innovative open source? (Message 33 to 42 of 62)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Darren New
Subject: Re: Innovative open source?
Date: 4 Apr 2009 12:51:45
Message: <49d79021$1@news.povray.org>
nemesis wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> But that's kind of the point. Why do you think that?  Saying "order
>> shouldn't matter because it's a set" is begging the question.
> 
> A set in the mathematical sense has no order.

I'm asking you why a dictionary shouldn't have order. You're saying "A 
dictionary is a set, so it shouldn't have order." But what makes a 
dictionary a set?

> If the guy wants order, he goes for a list.  

And now you're telling me how to work around the problem of sets not having 
order. See? :-)

Not that it's worth arguing. I'm just pointing out the logic is flawed.

> PHP only got array, so it has to play many roles.

Or, I could say "Python dictionaries are broken, so you need something else 
to substitute for when you want ordered pairs." Considering there are 
occasions when you want an order-maintaining dictionary, it would seem to be 
of benefit to have such built in.

>> Why does order matter in argument lists, if the arguments all need distinct
>> names anyway? :-)
> 
> I think it has to do with pragmatism:  it's just simpler to go with a list than
> a hash.

You're answering a rhetorical question. :-) I don't think you can argue that 
it's pragmatic to order argument lists but not pragmatic to order dictionaries.

> Named arguments is a thing of a hip generation used to lots of cheap computing
> power and general resources.

Errrrr... math generally doesn't use named arguments, even back when 
"computer" was a job title.

Anyway, I was trying to make a point, not especially to say one way is 
better than the other, but that both are equally valid approaches, modulo 
efficiency.

-- 
   Darren New, San Diego CA, USA (PST)
   There's no CD like OCD, there's no CD I knoooow!


Post a reply to this message

From: Darren New
Subject: Re: Innovative open source?
Date: 4 Apr 2009 12:52:37
Message: <49d79055$1@news.povray.org>
Kevin Wampler wrote:
> Darren New wrote:
>> Why does order matter in argument lists, if the arguments all need 
>> distinct names anyway? :-)
> 
> So you can call the function without explicitly naming the parameters, 
> thus reducing the amount of typing required.

It was a rhetorical question to show that the argument "dictionaries are 
sets and hence have no order" is an invalid comparison.

> Personally, I like the style where arguments can be passed in order (in 
> which case the names don't matter) or by name (in which case the order 
> doesn't matter).  Python sort does this, with a few restrictions, and 
> it's seemed pretty intuitive and useful to me.

Agreed.

> Thinking back, didn't objective-C use named parameters only for calling 
> object methods?  Did the order matter there?  I can't really remember.

Yes. Because they took it from Smalltalk.

-- 
   Darren New, San Diego CA, USA (PST)
   There's no CD like OCD, there's no CD I knoooow!


Post a reply to this message

From: nemesis
Subject: Re: Innovative open source?
Date: 4 Apr 2009 12:55:00
Message: <web.49d790d5aca2c31c1ec805060@news.povray.org>
Mueen Nawaz <m.n### [at] ieeeorg> wrote:
> nemesis wrote:
> > It can take arbitrary objects as keys and has a wealth of good methods to choose
> > from.  Perhaps it's time for some friday night troll? ;)
>
>  Unless they made changes, that's not correct. It can only take strings,
> numbers, and immutable types as keys (so no lists, but yes tuples).

Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> ls = dir()
>>> ls
['__builtins__', '__doc__', '__name__']
>>> d = {}
>>> d[ls]=1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: list objects are unhashable
>>> str
<type 'str'>
>>> d[str]="string class"
>>> d
{<type 'str'>: 'string class'}
>>> d[lambda x:x+1]="function object as key"
>>> d
{<type 'str'>: 'string class', <function <lambda> at 0x838aa3c>: 'function
object as key'}

True, lists can't be used as key.  But classes, objects and even functions can.


Post a reply to this message

From: Darren New
Subject: Re: Innovative open source?
Date: 4 Apr 2009 13:13:27
Message: <49d79537$1@news.povray.org>
Kevin Wampler wrote:
> I'm actually not sure what to expect here. 

Note that the "First Text" and "Second Text" keys stay in order, for 
example. I think it's pretty useful for things like representing stuff like 
XML, where you might want keys for the "id" field, but you also want to know 
what order the tags were in in the source file.

It looks like inserting something without an index puts it at the end of the 
array with an index one higher than the biggest integer index. Inserting 
something with an index overwrites what's at that index, or adds it to the 
end if the index doesn't already exist.

-- 
   Darren New, San Diego CA, USA (PST)
   There's no CD like OCD, there's no CD I knoooow!


Post a reply to this message


Attachments:
Download 'xyz.php.txt' (1 KB) Download 'xyz.txt' (1 KB)

From: nemesis
Subject: Re: Innovative open source?
Date: 4 Apr 2009 13:30:00
Message: <web.49d79851aca2c31c1ec805060@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> nemesis wrote:
> > Darren New <dne### [at] sanrrcom> wrote:
> >> But that's kind of the point. Why do you think that?  Saying "order
> >> shouldn't matter because it's a set" is begging the question.
> >
> > A set in the mathematical sense has no order.
>
> I'm asking you why a dictionary shouldn't have order. You're saying "A
> dictionary is a set, so it shouldn't have order." But what makes a
> dictionary a set?
>
> > If the guy wants order, he goes for a list.
>
> And now you're telling me how to work around the problem of sets not having
> order. See? :-)
>
> Not that it's worth arguing. I'm just pointing out the logic is flawed.
>
> > PHP only got array, so it has to play many roles.
>
> Or, I could say "Python dictionaries are broken, so you need something else
> to substitute for when you want ordered pairs."

You could say math is broken.

The primary function of a hash table is for lookup.  Looking up individual
registers associated with a given key.  No one said anything about order.

If you want order, append the keys to a list as they are inserted into the hash
and implement a display_hash function that will display hash items by iterating
over items from the list.

> Considering there are
> occasions when you want an order-maintaining dictionary, it would seem to be
> of benefit to have such built in.

Sure.  There's also plenty of practical benefits from having a language
automatically parse numbers out of strings such as v = "24"+1, as Perl and its
bastard son PHP do.

> > Named arguments is a thing of a hip generation used to lots of cheap computing
> > power and general resources.
>
> Errrrr... math generally doesn't use named arguments, even back when
> "computer" was a job title.

All the worse as mathematicians would need to write down far too much more
symbols on paper, rather than resorting to the simpler approach of following a
given order.  Lists are always simpler than sets.


Post a reply to this message

From: Darren New
Subject: Re: Innovative open source?
Date: 4 Apr 2009 13:48:57
Message: <49d79d89$1@news.povray.org>
nemesis wrote:
> The primary function of a hash table is for lookup.  Looking up individual
> registers associated with a given key.  No one said anything about order.

Yes. So... why is a "dict" a hashtable instead of something else?

Again, you're begging the question. You're asserting that the way Python 
does it is right, then justifying it based on the fact that Python decided 
to implement it that way. See?

You're saying "a hastable is for lookups. It doesn't have an order. 
Therefore, Python is right to base its data structures on hash tables."

> If you want order, append the keys to a list as they are inserted into the hash
> and implement a display_hash function that will display hash items by iterating
> over items from the list.

Well, there ya go. So why isn't that built in, like it is in PHP, since it 
allows both random and sequential lookups? :-)

> All the worse as mathematicians would need to write down far too much more
> symbols on paper, rather than resorting to the simpler approach of following a
> given order.  Lists are always simpler than sets.

So, it's OK for a mathematical set to maintain order when it's simpler, but 
it's not logical to make the data structures in your language have the same 
simplicity? I'm not following. :-)

-- 
   Darren New, San Diego CA, USA (PST)
   There's no CD like OCD, there's no CD I knoooow!


Post a reply to this message

From: andrel
Subject: Re: Innovative open source?
Date: 4 Apr 2009 13:59:01
Message: <49D79FE3.4040408@hotmail.com>
On 4-4-2009 18:45, nemesis wrote:
> andrel <a_l### [at] hotmailcom> wrote:
>> On 3-4-2009 23:08, nemesis wrote:
>>> andrel escreveu:
>>>> On 3-4-2009 18:40, Darren New wrote:
>>>>> Please, this is not a troll. It's a serious question that isn't meant
>>>>> to imply the answer is "no."
>>>> 'No' would be a strange answer to your question anyway.
>>>>
>>>>> What are some other cool open-source projects that didn't take their
>>>>> design from existing products?  I.e., ones where the open source
>>>>> software was the first thing to do things that way?
>>>> POV and Blender?
>>> Blender started life as an in-house, proprietary tool.  When the company
>>> was closing doors, they realized the tool was quite complete and good
>>> enough perhaps not for going commercial, but at least to serve as the
>>> basis for an open-source project.  And so they realized an online
>>> auction and when a certain ammount was gathered, they did release the
>>> source under the GPL.
>>>
>>> The community literally bought a former proprietary product and
>>> open-sourced it.  Even Stallman gone hurrah. :)
>> What I remember is that it started as a research project (at which stage
>> it may have been available for others, so that is why I though it might
>> qualify as an answer), was then tried commercially and when that did not
>> work converted to open source by the main developer.
>> The reason that it did not work may be related to being forced to do
>> (more than) full time 'maintenance' and 'support' because people were
>> paying.
>> That danger is why our software is available to fellow researchers for
>> free. We would like to do some research ourselves too.
> 
> First time I hear of such research history.  Are you sure you are talking about
> Blender?

I am sure I meant Blender, I am not sure if I am confusing some stories 
or filling in gaps. ;)
Memory is based on something someone that I worked with for some time 
told me some years ago.
He worked later in a group where one of the developers of Blender also 
ended up after NaN stopped. That was a group that was closely linked to 
a university, so I assumed he (not Ton Roosendaal) had a university 
background. So I just assumed it all started there.

> http://en.wikipedia.org/wiki/Blender_(software)#History

Given that my memory is not that good and it was mentioned in passing 
that is probably more accurate.


Post a reply to this message

From: nemesis
Subject: Re: Innovative open source?
Date: 4 Apr 2009 14:15:00
Message: <web.49d7a391aca2c31c1ec805060@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> You're saying "a hastable is for lookups. It doesn't have an order.
> Therefore, Python is right to base its data structures on hash tables."

It's supposed to be a hashtable.  If you don't want a hashtable, you shouldn't
use it.

> Well, there ya go. So why isn't that built in, like it is in PHP, since it
> allows both random and sequential lookups? :-)

Because Python, Scheme and Haskell attempt to use the correct approaches.  Form
follows function.

> So, it's OK for a mathematical set to maintain order when it's simpler,

A math set has no order.  I was saying the notation of functions over set
domains employs the convention of lists of arguments because it's simpler to
notate than named arguments out of order.

> it's not logical to make the data structures in your language have the same
> simplicity? I'm not following. :-)

Sure, just use a list if you want simplicity.  If you're using a hashtable,
you're stating order is not important.  Say:

x from XS, y from YS:
f(x, y) = x*x+y

You could call it, ordered:
f(1,2)
or unordered:
f(y=3,x=4)

They just crammed the 2 behaviours into a single multipurpose data
structure(less) in PHP.  Other languages have specialized data structures for
specific needs and that ought to be a good thing.


Post a reply to this message

From: Kevin Wampler
Subject: Re: Innovative open source?
Date: 4 Apr 2009 15:11:08
Message: <49d7b0cc$1@news.povray.org>
Darren New wrote:
> Kevin Wampler wrote:
>> Darren New wrote:
>>> Why does order matter in argument lists, if the arguments all need 
>>> distinct names anyway? :-)
>>
>> So you can call the function without explicitly naming the parameters, 
>> thus reducing the amount of typing required.
> 
> It was a rhetorical question to show that the argument "dictionaries are 
> sets and hence have no order" is an invalid comparison.

I should have guessed that.  It certainly seemed like an odd question 
for you to be asking in earnest.

>> Thinking back, didn't objective-C use named parameters only for 
>> calling object methods?  Did the order matter there?  I can't really 
>> remember.
> 
> Yes. Because they took it from Smalltalk.

That makes sense.  One of these days I'd like to get around to learning 
smalltalk.


Post a reply to this message

From: Kevin Wampler
Subject: Re: Innovative open source?
Date: 4 Apr 2009 15:12:44
Message: <49d7b12c$1@news.povray.org>
Darren New wrote:
> Kevin Wampler wrote:
>> I'm actually not sure what to expect here. 
> 
> Note that the "First Text" and "Second Text" keys stay in order, for 
> example. I think it's pretty useful for things like representing stuff 
> like XML, where you might want keys for the "id" field, but you also 
> want to know what order the tags were in in the source file.

Ahh, yeah, that's exactly the sort of use case I was looking for.

> It looks like inserting something without an index puts it at the end of 
> the array with an index one higher than the biggest integer index. 
> Inserting something with an index overwrites what's at that index, or 
> adds it to the end if the index doesn't already exist.

Good to know.  Thanks!


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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