- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
first vs head
Thu, 2009-12-17, 12:53
I'm testing 2.8 and I get these warnings:
method first in trait IterableLike is deprecated: use `head' instead
Does somebody know why "first" is deprecated?
IMO "head" is way less intuitive than "first" - which reveals much
more clearly the intent.
> (1 until 10).first
against
> (1 until 10).head
Which one do you prefer, and... couldn't both just co-exist?
Thanks,
Francisco
Thu, 2009-12-17, 17:47
#2
Re: first vs head
francisco treacy wrote:
> I'm testing 2.8 and I get these warnings:
>
> method first in trait IterableLike is deprecated: use `head' instead
>
> Does somebody know why "first" is deprecated?
head/tail are in the tradition of statically typed functional languages
such as Haskell and ML(s).
+1 for head/tail :-)
Paolo
Thu, 2009-12-17, 18:17
#3
Re: first vs head
Interesting point, Paolo.
Actually I am eager to know what the community inclines for, keeping
tradition or going for an intuitive option (in my opinion).
Or both :)
Mirko: That's right, we would need an alias for "tail", such as "rest" :)
Francisco
2009/12/17 Paolo Losi :
>
>
> francisco treacy wrote:
>>
>> I'm testing 2.8 and I get these warnings:
>>
>> method first in trait IterableLike is deprecated: use `head' instead
>>
>> Does somebody know why "first" is deprecated?
>
> head/tail are in the tradition of statically typed functional languages
> such as Haskell and ML(s).
>
> +1 for head/tail :-)
>
> Paolo
>
>
>
Thu, 2009-12-17, 18:37
#4
Re: Re: first vs head
+1 for first and last
isn't that still the way LinearSeqLike goes? i guess 'first' and 'last' imply an ordering of the sequence, hence deprecated in IterableLike. (i cannot check whether they are deprecated in LinearSeqLike, the ugly new scaladoc formatting doesn't show deprecation any more: http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/... )
i'm happy that 'rest' has gone as far as i see. that was the most unintuitive naming.
ciao, -sciss-
Am 17.12.2009 um 17:08 schrieb francisco treacy:
> Interesting point, Paolo.
> Actually I am eager to know what the community inclines for, keeping
> tradition or going for an intuitive option (in my opinion).
>
> Or both :)
>
> Mirko: That's right, we would need an alias for "tail", such as "rest" :)
>
> Francisco
>
>
> 2009/12/17 Paolo Losi :
>>
>>
>> francisco treacy wrote:
>>>
>>> I'm testing 2.8 and I get these warnings:
>>>
>>> method first in trait IterableLike is deprecated: use `head' instead
>>>
>>> Does somebody know why "first" is deprecated?
>>
>> head/tail are in the tradition of statically typed functional languages
>> such as Haskell and ML(s).
>>
>> +1 for head/tail :-)
>>
>> Paolo
>>
>>
>>
Thu, 2009-12-17, 18:47
#5
Re: Re: first vs head
but head and tail are entirely intuitive :)
+1 for conventional naming for list data structure access (head and tail)
Scala lists are functionally orientated (immutable, higher order functions) so the naming reflects that quite nicely?
anyway this naming predates and transcends Haskell and MLs. first and rest sounds like an M$ naming convention ;)
Definitely not both, surely redundant and pointless!
PS: you'll never get everyone to agree on something subjective like this :)
--
www.chillipower.com
http://louisbotterill.blogspot.com/
Please consider your environmental responsibility before printing this e-mail
+1 for conventional naming for list data structure access (head and tail)
Scala lists are functionally orientated (immutable, higher order functions) so the naming reflects that quite nicely?
anyway this naming predates and transcends Haskell and MLs. first and rest sounds like an M$ naming convention ;)
Definitely not both, surely redundant and pointless!
PS: you'll never get everyone to agree on something subjective like this :)
--
www.chillipower.com
http://louisbotterill.blogspot.com/
Please consider your environmental responsibility before printing this e-mail
Thu, 2009-12-17, 18:47
#6
Re: Re: first vs head
I vote for -~> for tail, because it kind of looks like a tail. Or maybe there's a Unicode character out there for it.
Anyone have some good ASCII art or unicode characters that look like a head and a tail?
(yeah, no one is going to agree, best there be one reasonable way to do it)
On Thu, Dec 17, 2009 at 12:33 PM, Louis Botterill <chillipower.uk@gmail.com> wrote:
--
http://erikengbrecht.blogspot.com/
Anyone have some good ASCII art or unicode characters that look like a head and a tail?
(yeah, no one is going to agree, best there be one reasonable way to do it)
On Thu, Dec 17, 2009 at 12:33 PM, Louis Botterill <chillipower.uk@gmail.com> wrote:
but head and tail are entirely intuitive :)
+1 for conventional naming for list data structure access (head and tail)
Scala lists are functionally orientated (immutable, higher order functions) so the naming reflects that quite nicely?
anyway this naming predates and transcends Haskell and MLs. first and rest sounds like an M$ naming convention ;)
Definitely not both, surely redundant and pointless!
PS: you'll never get everyone to agree on something subjective like this :)
--
www.chillipower.com
http://louisbotterill.blogspot.com/
Please consider your environmental responsibility before printing this e-mail
--
http://erikengbrecht.blogspot.com/
Thu, 2009-12-17, 18:47
#7
Re: Re: first vs head
I think we should use: head and abdomen
and we could also have a thorax method to get the second element or something. ;-)
I agree no one will agree. But I will add that I came from a C++ background so head and tail seemed unnatural at first (in LISP is there I encountered them, I think they were just aliases for cdr and car) but now they seem very natural and I don't even mind using them on non-linked lists where the terms don't actually describe the structure.
Oh and I strongly disagree with calling tail "last". Last should get the last element not the tail. The only other reasonable name that has been mentioned is rest.
-Arthur
On Thu, Dec 17, 2009 at 12:38 PM, Erik Engbrecht <erik.engbrecht@gmail.com> wrote:
and we could also have a thorax method to get the second element or something. ;-)
I agree no one will agree. But I will add that I came from a C++ background so head and tail seemed unnatural at first (in LISP is there I encountered them, I think they were just aliases for cdr and car) but now they seem very natural and I don't even mind using them on non-linked lists where the terms don't actually describe the structure.
Oh and I strongly disagree with calling tail "last". Last should get the last element not the tail. The only other reasonable name that has been mentioned is rest.
-Arthur
On Thu, Dec 17, 2009 at 12:38 PM, Erik Engbrecht <erik.engbrecht@gmail.com> wrote:
I vote for -~> for tail, because it kind of looks like a tail. Or maybe there's a Unicode character out there for it.
Anyone have some good ASCII art or unicode characters that look like a head and a tail?
(yeah, no one is going to agree, best there be one reasonable way to do it)
On Thu, Dec 17, 2009 at 12:33 PM, Louis Botterill <chillipower.uk@gmail.com> wrote:
but head and tail are entirely intuitive :)
+1 for conventional naming for list data structure access (head and tail)
Scala lists are functionally orientated (immutable, higher order functions) so the naming reflects that quite nicely?
anyway this naming predates and transcends Haskell and MLs. first and rest sounds like an M$ naming convention ;)
Definitely not both, surely redundant and pointless!
PS: you'll never get everyone to agree on something subjective like this :)
--
www.chillipower.com
http://louisbotterill.blogspot.com/
Please consider your environmental responsibility before printing this e-mail
--
http://erikengbrecht.blogspot.com/
Thu, 2009-12-17, 18:57
#8
Re: Re: first vs head
Hi,
>+1 for first and last
but last isn't the same as tail or rest though?
Java List interface has first and last, but then this is a mutable list that allows direct access by index... (so last makes some sense), in a recursive structure all you really have is head and tail for each element
Maybe that's part of the issue as well, first might also imply a last too?
--
www.chillipower.com
http://louisbotterill.blogspot.com/
Please consider your environmental responsibility before printing this e-mail
>+1 for first and last
but last isn't the same as tail or rest though?
Java List interface has first and last, but then this is a mutable list that allows direct access by index... (so last makes some sense), in a recursive structure all you really have is head and tail for each element
Maybe that's part of the issue as well, first might also imply a last too?
--
www.chillipower.com
http://louisbotterill.blogspot.com/
Please consider your environmental responsibility before printing this e-mail
Thu, 2009-12-17, 18:57
#9
Re: Re: first vs head
i don't know who is mixing it up, but if you google
http://www.google.com/search?q=list+head+tail+pred+succ&btnG=Suche&lr=&a...
i come to a bunch of typical linked list implementations (check the first result for example), each of which is refering to the _last_ element as tail, not the cdr! i don't think head / tail is therefore synonymous with car / cdr.
also think of tail-recursion, isn't that referring to the last element instead of "everything but the head"?
ciao, -sciss-
Am 17.12.2009 um 17:46 schrieb Arthur Peters:
> I think we should use: head and abdomen
>
> and we could also have a thorax method to get the second element or something. ;-)
>
> I agree no one will agree. But I will add that I came from a C++ background so head and tail seemed unnatural at first (in LISP is there I encountered them, I think they were just aliases for cdr and car) but now they seem very natural and I don't even mind using them on non-linked lists where the terms don't actually describe the structure.
>
> Oh and I strongly disagree with calling tail "last". Last should get the last element not the tail. The only other reasonable name that has been mentioned is rest.
>
> -Arthur
>
>
> On Thu, Dec 17, 2009 at 12:38 PM, Erik Engbrecht wrote:
> I vote for -~> for tail, because it kind of looks like a tail. Or maybe there's a Unicode character out there for it.
>
> Anyone have some good ASCII art or unicode characters that look like a head and a tail?
>
> (yeah, no one is going to agree, best there be one reasonable way to do it)
>
>
> On Thu, Dec 17, 2009 at 12:33 PM, Louis Botterill wrote:
> but head and tail are entirely intuitive :)
>
> +1 for conventional naming for list data structure access (head and tail)
>
> Scala lists are functionally orientated (immutable, higher order functions) so the naming reflects that quite nicely?
>
> anyway this naming predates and transcends Haskell and MLs. first and rest sounds like an M$ naming convention ;)
>
> Definitely not both, surely redundant and pointless!
>
> PS: you'll never get everyone to agree on something subjective like this :)
>
>
Thu, 2009-12-17, 19:07
#10
Re: first vs head
I'd have said head / tail is to do with how a list is implemented, while
first / last is about what you want out of any collection.
Bugzilla from me@misto.ch wrote:
>
> On Thursday 17 December 2009 12:53:27 francisco treacy wrote:
>> Which one do you prefer, and... couldn't both just co-exist?
>
> I guess it's because of the symmetry: head <-> tail, and if first would
> stay,
> then "rest" or something would be needed to complement first. Or car and
> cdr
> :-)
>
> Regards
>
> Mirko
>
>
Thu, 2009-12-17, 19:17
#11
Re: Re: first vs head
(maybe it's a german speciality, don't know. here's another one: http://www.pri.univie.ac.at/~schiki/unterlagen/GAlgoDat/KAPITEL5.pdf --> look for 'tail' )
Am 17.12.2009 um 17:56 schrieb Sciss:
> i don't know who is mixing it up, but if you google
>
> http://www.google.com/search?q=list+head+tail+pred+succ&btnG=Suche&lr=&a...
>
> i come to a bunch of typical linked list implementations (check the first result for example), each of which is refering to the _last_ element as tail, not the cdr! i don't think head / tail is therefore synonymous with car / cdr.
>
> also think of tail-recursion, isn't that referring to the last element instead of "everything but the head"?
>
> ciao, -sciss-
>
>
> Am 17.12.2009 um 17:46 schrieb Arthur Peters:
>
>> I think we should use: head and abdomen
>>
>> and we could also have a thorax method to get the second element or something. ;-)
>>
>> I agree no one will agree. But I will add that I came from a C++ background so head and tail seemed unnatural at first (in LISP is there I encountered them, I think they were just aliases for cdr and car) but now they seem very natural and I don't even mind using them on non-linked lists where the terms don't actually describe the structure.
>>
>> Oh and I strongly disagree with calling tail "last". Last should get the last element not the tail. The only other reasonable name that has been mentioned is rest.
>>
>> -Arthur
>>
>>
>> On Thu, Dec 17, 2009 at 12:38 PM, Erik Engbrecht wrote:
>> I vote for -~> for tail, because it kind of looks like a tail. Or maybe there's a Unicode character out there for it.
>>
>> Anyone have some good ASCII art or unicode characters that look like a head and a tail?
>>
>> (yeah, no one is going to agree, best there be one reasonable way to do it)
>>
>>
>> On Thu, Dec 17, 2009 at 12:33 PM, Louis Botterill wrote:
>> but head and tail are entirely intuitive :)
>>
>> +1 for conventional naming for list data structure access (head and tail)
>>
>> Scala lists are functionally orientated (immutable, higher order functions) so the naming reflects that quite nicely?
>>
>> anyway this naming predates and transcends Haskell and MLs. first and rest sounds like an M$ naming convention ;)
>>
>> Definitely not both, surely redundant and pointless!
>>
>> PS: you'll never get everyone to agree on something subjective like this :)
>>
>>
Thu, 2009-12-17, 19:17
#12
Re: first vs head
On Thursday December 17 2009, Marcus Downing wrote:
> I'd have said head / tail is to do with how a list is implemented,
> while first / last is about what you want out of any collection.
That is not really true. Lists in their functional definition can only
be implemented as Lisp cons cells are (by any name). There is always a
distinguished "empty list" (Nil, e.g.) and a two-argument function
("cons" or "::", e.g.) whose second argument is restricted to being
another list (either the result of applying the cons function or the
empty list / nil).
Choice of names aside, the first/rest or head/tail concept is essential
to the very definition of a list (a functional list, i.e.).
And arrays or ArrayLists and whatnot are _not_ lists in the functional
sense.
Randall Schulz
Thu, 2009-12-17, 19:47
#13
Re: Re: first vs head
On Thursday 17 December 2009 18:38:47 Erik Engbrecht wrote:
> Anyone have some good ASCII art or unicode characters that look like a head
> and a tail?
What about ⇱ for the head and ⇲ for the tail? :-) Or this one's nice too: ⟿
here are some really crazy arrows:
http://www.alanwood.net/unicode/supplemental_arrows_b.html
Cheers :-)
Mirko
Thu, 2009-12-17, 21:07
#14
Re: first vs head
Interesting that in this long thread, no one actually addressed the real reason, which is that head and tail are defined on Traversable.
In case you are scratching your head and wondering what the heck, consider a Set or a Map. Does it have any meaning to speak of the "first" of a Set? Now, for something funny, let's check the documentation:
--
Daniel C. Sobral
I travel to the future all the time.
Selects the first element.
Note: might return different results for different runs, unless the underlying collection type is ordered.
Hehehhe. Selects the _first_ element. :-)
Anyway, the decision was made. Going back-and-forth on this issue (like it HAS happened) is worse than sticking with a slightly bad choice.
On Thu, Dec 17, 2009 at 9:53 AM, francisco treacy <francisco.treacy@gmail.com> wrote:
I'm testing 2.8 and I get these warnings:
method first in trait IterableLike is deprecated: use `head' instead
Does somebody know why "first" is deprecated?
IMO "head" is way less intuitive than "first" - which reveals much
more clearly the intent.
> (1 until 10).first
against
> (1 until 10).head
Which one do you prefer, and... couldn't both just co-exist?
Thanks,
Francisco
--
Daniel C. Sobral
I travel to the future all the time.
Thu, 2009-12-17, 21:37
#15
Re: first vs head
On Thu, Dec 17, 2009 at 05:57:20PM -0200, Daniel Sobral wrote:
> Interesting that in this long thread, no one actually addressed the
> real reason, which is that head and tail are defined on Traversable.
Whoa, what? Why? The naming discussion is another exercise in
pointlessness, but that's not. What is the difference between head and
last (or tail and init, or headOption and lastOption) on Traversable?
Some days I'm not at all sure what purpose Traversable serves.
Thu, 2009-12-17, 22:07
#16
Re: first vs head
First implies ordering, which is not guaranteed by non-ordered collections. So, a method common to all collections (ie, defined at Traversable), shouldn't imply so.
I'm not trying to justify it, just repeating the argument I heard.
On Thu, Dec 17, 2009 at 6:34 PM, Paul Phillips <paulp@improving.org> wrote:
--
Daniel C. Sobral
I travel to the future all the time.
On Thu, Dec 17, 2009 at 6:34 PM, Paul Phillips <paulp@improving.org> wrote:
On Thu, Dec 17, 2009 at 05:57:20PM -0200, Daniel Sobral wrote:
> Interesting that in this long thread, no one actually addressed the
> real reason, which is that head and tail are defined on Traversable.
Whoa, what? Why? The naming discussion is another exercise in
pointlessness, but that's not. What is the difference between head and
last (or tail and init, or headOption and lastOption) on Traversable?
Some days I'm not at all sure what purpose Traversable serves.
--
Paul Phillips | On two occasions, I have been asked, 'Mr. Babbage, if you
Caged Spirit | put into the machine wrong figures, will the right answers
Empiricist | come out?' I am not able to rightly apprehend the kind of
up hill, pi pals! | confusion of ideas that could provoke such a question.
--
Daniel C. Sobral
I travel to the future all the time.
Thu, 2009-12-17, 22:37
#17
Re: first vs head
Traversable by itself does not give you any guarantee of ordering.
But even if head picks a random element of a Traversable and tail
picks the rest, that's still enough for quite a lot of algorithms that
work
on traversables.
Cheers
Thu, 2009-12-17, 23:17
#18
Re: first vs head
Would it make sense then to provide 'first' on all ordered
collections, but not in non-ordered?
My question was from a purely aesthetic point of view of the API. I
heavily use the head/first of Lists throughout my code and I think
'first' reveals much more intent than when I see 'head's.
(This is one of the reasons I like Ruby so much).
Regards,
Francisco
2009/12/17 martin odersky :
> Traversable by itself does not give you any guarantee of ordering.
> But even if head picks a random element of a Traversable and tail
> picks the rest, that's still enough for quite a lot of algorithms that
> work
> on traversables.
>
> Cheers
>
> -- Martin
>
Fri, 2009-12-18, 16:57
#19
Re: first vs head
What about endless lists (Stream) what is last in this case?
+1 for head/tail
Regards Stefan
+1 for head/tail
Regards Stefan
Fri, 2009-12-18, 17:07
#20
Re: first vs head
On Fri, Dec 18, 2009 at 18:52, Stefan Langer
wrote:
> What about endless lists (Stream) what is last in this case?
>
> +1 for head/tail
+1 for both.
S.
Fri, 2009-12-18, 17:17
#21
Re: first vs head
On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer <mailtolanger@googlemail.com> wrote:
What about endless lists (Stream) what is last in this case?
+1 for head/tail
head/neck
Regards Stefan
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Blog: klangism.blogspot.com
Twttr: twitter.com/viktorklang
Code: github.com/viktorklang
Sat, 2009-12-19, 16:17
#22
Re: first vs head
>> What about endless lists (Stream) what is last in this case?
Let's focus on the original question, about why "first" is deprecated.
Compare again:
(html \\ "span") head
(html \\ "span") first
The latter clearly reveals the intent much better.
I want "first" back. I know this might look trivial but it is not. It
adds up to make the language more unreadable. I cannot even fix the
deprecation warning with an implicit.
So, would it be possible to bring it back? Or should I take this to
scala-debate or scala-internals?
Thanks,
Francisco
2009/12/18 Viktor Klang :
>
>
> On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer
> wrote:
>>
>> What about endless lists (Stream) what is last in this case?
>>
>> +1 for head/tail
>
> head/neck
>
>>
>> Regards Stefan
>
>
>
> --
> Viktor Klang
> | "A complex system that works is invariably
> | found to have evolved from a simple system
> | that worked." - John Gall
>
> Blog: klangism.blogspot.com
> Twttr: twitter.com/viktorklang
> Code: github.com/viktorklang
>
Sat, 2009-12-19, 16:27
#23
Re: first vs head
Scala debate is the proper place. And I agree first makes a lot of sense for _sequences_, so you may want to focus your efforts there.
On Sat, Dec 19, 2009 at 1:16 PM, francisco treacy <francisco.treacy@gmail.com> wrote:
--
Daniel C. Sobral
I travel to the future all the time.
On Sat, Dec 19, 2009 at 1:16 PM, francisco treacy <francisco.treacy@gmail.com> wrote:
>> What about endless lists (Stream) what is last in this case?
Let's focus on the original question, about why "first" is deprecated.
Compare again:
(html \\ "span") head
(html \\ "span") first
The latter clearly reveals the intent much better.
I want "first" back. I know this might look trivial but it is not. It
adds up to make the language more unreadable. I cannot even fix the
deprecation warning with an implicit.
So, would it be possible to bring it back? Or should I take this to
scala-debate or scala-internals?
Thanks,
Francisco
2009/12/18 Viktor Klang <viktor.klang@gmail.com>:
>
>
> On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer <mailtolanger@googlemail.com>
> wrote:
>>
>> What about endless lists (Stream) what is last in this case?
>>
>> +1 for head/tail
>
> head/neck
>
>>
>> Regards Stefan
>
>
>
> --
> Viktor Klang
> | "A complex system that works is invariably
> | found to have evolved from a simple system
> | that worked." - John Gall
>
> Blog: klangism.blogspot.com
> Twttr: twitter.com/viktorklang
> Code: github.com/viktorklang
>
--
Daniel C. Sobral
I travel to the future all the time.
Sat, 2009-12-19, 16:37
#24
Re: first vs head
Other languages have offered multiple ways of achieving the same thing (*cough* perl *cough*), what tends to happen is that so many idioms and styles become established that you can almost guarantee to find *something* in any piece of source code that's incomprehensible to you.
Given that, it makes a great deal of sense to have only one way to achieve this task. The possibilities are: - head/tail - first/lastOf these, we want to chose just ONE option, and use it consistently across the API
first/last is unpopular because 'last' implies just a single element, which is wrong, and also makes no sense at all in the presence of streams. Which leaves us with just head/tail and a very strong desire to not offer alternative names for identical functionality.
So my vote for the idea of re-introducing the 'first' operation must absolutely be -100
2009/12/19 francisco treacy <francisco.treacy@gmail.com>
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Given that, it makes a great deal of sense to have only one way to achieve this task. The possibilities are: - head/tail - first/lastOf these, we want to chose just ONE option, and use it consistently across the API
first/last is unpopular because 'last' implies just a single element, which is wrong, and also makes no sense at all in the presence of streams. Which leaves us with just head/tail and a very strong desire to not offer alternative names for identical functionality.
So my vote for the idea of re-introducing the 'first' operation must absolutely be -100
2009/12/19 francisco treacy <francisco.treacy@gmail.com>
>> What about endless lists (Stream) what is last in this case?
Let's focus on the original question, about why "first" is deprecated.
Compare again:
(html \\ "span") head
(html \\ "span") first
The latter clearly reveals the intent much better.
I want "first" back. I know this might look trivial but it is not. It
adds up to make the language more unreadable. I cannot even fix the
deprecation warning with an implicit.
So, would it be possible to bring it back? Or should I take this to
scala-debate or scala-internals?
Thanks,
Francisco
2009/12/18 Viktor Klang <viktor.klang@gmail.com>:
>
>
> On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer <mailtolanger@googlemail.com>
> wrote:
>>
>> What about endless lists (Stream) what is last in this case?
>>
>> +1 for head/tail
>
> head/neck
>
>>
>> Regards Stefan
>
>
>
> --
> Viktor Klang
> | "A complex system that works is invariably
> | found to have evolved from a simple system
> | that worked." - John Gall
>
> Blog: klangism.blogspot.com
> Twttr: twitter.com/viktorklang
> Code: github.com/viktorklang
>
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Sat, 2009-12-19, 17:27
#25
Re: first vs head
That would be first/rest, particularly since last is already pair to init.
On Sat, Dec 19, 2009 at 1:25 PM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
--
Daniel C. Sobral
I travel to the future all the time.
On Sat, Dec 19, 2009 at 1:25 PM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
Other languages have offered multiple ways of achieving the same thing (*cough* perl *cough*), what tends to happen is that so many idioms and styles become established that you can almost guarantee to find *something* in any piece of source code that's incomprehensible to you.
Given that, it makes a great deal of sense to have only one way to achieve this task. The possibilities are: - head/tail - first/lastOf these, we want to chose just ONE option, and use it consistently across the API
first/last is unpopular because 'last' implies just a single element, which is wrong, and also makes no sense at all in the presence of streams. Which leaves us with just head/tail and a very strong desire to not offer alternative names for identical functionality.
So my vote for the idea of re-introducing the 'first' operation must absolutely be -100
2009/12/19 francisco treacy <francisco.treacy@gmail.com>
>> What about endless lists (Stream) what is last in this case?
Let's focus on the original question, about why "first" is deprecated.
Compare again:
(html \\ "span") head
(html \\ "span") first
The latter clearly reveals the intent much better.
I want "first" back. I know this might look trivial but it is not. It
adds up to make the language more unreadable. I cannot even fix the
deprecation warning with an implicit.
So, would it be possible to bring it back? Or should I take this to
scala-debate or scala-internals?
Thanks,
Francisco
2009/12/18 Viktor Klang <viktor.klang@gmail.com>:
>
>
> On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer <mailtolanger@googlemail.com>
> wrote:
>>
>> What about endless lists (Stream) what is last in this case?
>>
>> +1 for head/tail
>
> head/neck
>
>>
>> Regards Stefan
>
>
>
> --
> Viktor Klang
> | "A complex system that works is invariably
> | found to have evolved from a simple system
> | that worked." - John Gall
>
> Blog: klangism.blogspot.com
> Twttr: twitter.com/viktorklang
> Code: github.com/viktorklang
>
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
--
Daniel C. Sobral
I travel to the future all the time.
Sat, 2009-12-19, 17:47
#26
Re: first vs head
>>>>> "Kevin" == Kevin Wright writes:
Kevin> The possibilities are: - head/tail -
Kevin> first/last
first/rest, not first/last
Kevin> first/last is unpopular because 'last' implies just a single
Kevin> element, which is wrong
Of course that's wrong -- I really don't think anyone was ever
suggesting making "last" synonymous with "tail".
Sat, 2009-12-19, 18:07
#27
Re: first vs head
2009/12/19 Daniel Sobral <dcsobral@gmail.com>
That would be first/rest, particularly since last is already pair to init.
Yikes, 'rest' is even worse, in the wrong context it might be seen as a synonym for yield, or the REST acronym. This is definitely the issue with first though, what would the complimentary operation be named?
head/tail has the advantage of being a well known, established convention. At least in the FP world :)
On Sat, Dec 19, 2009 at 1:25 PM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
Other languages have offered multiple ways of achieving the same thing (*cough* perl *cough*), what tends to happen is that so many idioms and styles become established that you can almost guarantee to find *something* in any piece of source code that's incomprehensible to you.
Given that, it makes a great deal of sense to have only one way to achieve this task. The possibilities are: - head/tail - first/lastOf these, we want to chose just ONE option, and use it consistently across the API
first/last is unpopular because 'last' implies just a single element, which is wrong, and also makes no sense at all in the presence of streams. Which leaves us with just head/tail and a very strong desire to not offer alternative names for identical functionality.
So my vote for the idea of re-introducing the 'first' operation must absolutely be -100
2009/12/19 francisco treacy <francisco.treacy@gmail.com>
>> What about endless lists (Stream) what is last in this case?
Let's focus on the original question, about why "first" is deprecated.
Compare again:
(html \\ "span") head
(html \\ "span") first
The latter clearly reveals the intent much better.
I want "first" back. I know this might look trivial but it is not. It
adds up to make the language more unreadable. I cannot even fix the
deprecation warning with an implicit.
So, would it be possible to bring it back? Or should I take this to
scala-debate or scala-internals?
Thanks,
Francisco
2009/12/18 Viktor Klang <viktor.klang@gmail.com>:
>
>
> On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer <mailtolanger@googlemail.com>
> wrote:
>>
>> What about endless lists (Stream) what is last in this case?
>>
>> +1 for head/tail
>
> head/neck
>
>>
>> Regards Stefan
>
>
>
> --
> Viktor Klang
> | "A complex system that works is invariably
> | found to have evolved from a simple system
> | that worked." - John Gall
>
> Blog: klangism.blogspot.com
> Twttr: twitter.com/viktorklang
> Code: github.com/viktorklang
>
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
--
Daniel C. Sobral
I travel to the future all the time.
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
Fri, 2010-01-08, 14:37
#28
Re: first vs head
(moving to scala-debate)
Aye, well my 2¢—though I fear that this will probably go round and round in circles since it’s the sort of thing that people prefer what they’re used to—and it seems to be a bit close to the release of 2.8 to change any of it—is:
‘first’ and ‘last’ (meaning first element and last element) seem to me to be useful and accurate terms when talking in the abstract. (It’s not even clear what word you’d use to mean the last element if the first element is called ‘head’—‘tipOfTheTail’?. ‘head’/‘last’ has a horrible lack of symmetry.) ‘rest’ seams a reasonably neutral way to refer to ‘everything except the first element’. But then ‘tail’ has meant that for longer.
Well, aye, but we’re talking about the context of elements of a collection/sequence! In the wrong context, lots of terms get confusing.
However, for singly-linked lists—and in fact streams of values which possibly don’t allow random access, ‘head’ and ‘tail’ are conventional terms.
I think “some collections don’t specify an ordering therefore it shouldn’t be called ‘first’” is a bit of a red herring, because Traversable does define a ‘last’ method, and by that argument it shouldn’t. ‘first’ and ‘last’ (in this context) are defined by the order of traversal, not the (nonexistant) natural order of the collection.
For comparison, Clojure uses ‘first’ and ‘rest’ for abstract sequences, and ‘head’ and ‘tail’ for linked lists. This seems sensible to me.
In summary: in any context where you can call ‘last’, you should also be able to call ‘first’. ‘head’/‘last’ is ugly. I really don’t have strong opinions about ‘tail’ vs. ‘rest’. The meaning of ‘tail’ is more firmly established, and there are no existing ‘rest’ methods as far as I can see, so I’d be for sticking with ‘tail’. ‘first’/‘tail’ is perfectly fine, I think.
–Andrew
On 19 Dec 2009, at 17:03, Kevin Wright wrote:
Aye, well my 2¢—though I fear that this will probably go round and round in circles since it’s the sort of thing that people prefer what they’re used to—and it seems to be a bit close to the release of 2.8 to change any of it—is:
‘first’ and ‘last’ (meaning first element and last element) seem to me to be useful and accurate terms when talking in the abstract. (It’s not even clear what word you’d use to mean the last element if the first element is called ‘head’—‘tipOfTheTail’?. ‘head’/‘last’ has a horrible lack of symmetry.) ‘rest’ seams a reasonably neutral way to refer to ‘everything except the first element’. But then ‘tail’ has meant that for longer.
Yikes, 'rest' is even worse, in the wrong context it might be seen as a synonym for yield, or the REST acronym.
Well, aye, but we’re talking about the context of elements of a collection/sequence! In the wrong context, lots of terms get confusing.
However, for singly-linked lists—and in fact streams of values which possibly don’t allow random access, ‘head’ and ‘tail’ are conventional terms.
I think “some collections don’t specify an ordering therefore it shouldn’t be called ‘first’” is a bit of a red herring, because Traversable does define a ‘last’ method, and by that argument it shouldn’t. ‘first’ and ‘last’ (in this context) are defined by the order of traversal, not the (nonexistant) natural order of the collection.
For comparison, Clojure uses ‘first’ and ‘rest’ for abstract sequences, and ‘head’ and ‘tail’ for linked lists. This seems sensible to me.
In summary: in any context where you can call ‘last’, you should also be able to call ‘first’. ‘head’/‘last’ is ugly. I really don’t have strong opinions about ‘tail’ vs. ‘rest’. The meaning of ‘tail’ is more firmly established, and there are no existing ‘rest’ methods as far as I can see, so I’d be for sticking with ‘tail’. ‘first’/‘tail’ is perfectly fine, I think.
–Andrew
On 19 Dec 2009, at 17:03, Kevin Wright wrote:
2009/12/19 Daniel Sobral <dcsobral@gmail.com>That would be first/rest, particularly since last is already pair to init.
head/tail has the advantage of being a well known, established convention. At least in the FP world :)
On Sat, Dec 19, 2009 at 1:25 PM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
Other languages have offered multiple ways of achieving the same thing (*cough* perl *cough*), what tends to happen is that so many idioms and styles become established that you can almost guarantee to find *something* in any piece of source code that's incomprehensible to you.
Given that, it makes a great deal of sense to have only one way to achieve this task. The possibilities are: - head/tail - first/lastOf these, we want to chose just ONE option, and use it consistently across the API
first/last is unpopular because 'last' implies just a single element, which is wrong, and also makes no sense at all in the presence of streams. Which leaves us with just head/tail and a very strong desire to not offer alternative names for identical functionality.
So my vote for the idea of re-introducing the 'first' operation must absolutely be -100
2009/12/19 francisco treacy <francisco.treacy@gmail.com>
>> What about endless lists (Stream) what is last in this case?
Let's focus on the original question, about why "first" is deprecated.
Compare again:
(html \\ "span") head
(html \\ "span") first
The latter clearly reveals the intent much better.
I want "first" back. I know this might look trivial but it is not. It
adds up to make the language more unreadable. I cannot even fix the
deprecation warning with an implicit.
So, would it be possible to bring it back? Or should I take this to
scala-debate or scala-internals?
Thanks,
Francisco
2009/12/18 Viktor Klang <viktor.klang@gmail.com>:
>
>
> On Fri, Dec 18, 2009 at 4:52 PM, Stefan Langer <mailtolanger@googlemail.com>
> wrote:
>>
>> What about endless lists (Stream) what is last in this case?
>>
>> +1 for head/tail
>
> head/neck
>
>>
>> Regards Stefan
>
>
>
> --
> Viktor Klang
> | "A complex system that works is invariably
> | found to have evolved from a simple system
> | that worked." - John Gall
>
> Blog: klangism.blogspot.com
> Twttr: twitter.com/viktorklang
> Code: github.com/viktorklang
>
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
--
Daniel C. Sobral
I travel to the future all the time.
--
Kevin Wright
mail/google talk: kev.lee.wright@googlemail.com
wave: kev.lee.wright@googlewave.com
skype: kev.lee.wright
twitter: @thecoda
On Thursday 17 December 2009 12:53:27 francisco treacy wrote:
> Which one do you prefer, and... couldn't both just co-exist?
I guess it's because of the symmetry: head <-> tail, and if first would stay,
then "rest" or something would be needed to complement first. Or car and cdr
:-)
Regards
Mirko