Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

head reverse annoys me

 [1/27] from: carl::rebol::net at: 16-Dec-2004 12:01


I'm not sure if anyone has been annoyed by REVERSE returning the tail position. I know I have. Everywhere I see REVERSE used like this: ... head reverse foo. It's my fault. I defined REVERSE like this for the same reason I defined INSERT and other series functions to do the same: to not lose "information" (in other words to preserve the ending location). But, that feature is rarely, if ever, used (in REVERSE that is). I'm inclined to change it to return the starting location, but I thought it might be good to discuss this openly. Will such a change break existing code? It could, if anyone uses the result of REVERSE. But, that would surprise me. I've never used it in "millions" of lines of code. (That's like dog years.) It's a small thing, but I don't like new users to get annoyed with stuff like this. Say the word, and it will be done by sundown today. -Carl

 [2/27] from: SunandaDH:aol at: 16-Dec-2004 15:29


Carl:
> I'm not sure if anyone has been annoyed by REVERSE returning > the tail position. I know I have. Everywhere I see REVERSE used > like this: ... head reverse foo.
Annoying? Yes.. But used? Yes -- quite commonly. I've scanned a pile of code and found it on several occasions. Typically something like: if user-display-option = "earliest first" [ data: head reverse data ] foreach item data [ .... ] Sadly, all that code would break. How about a related word? invert: func [item] [head reverse item] Sunanda

 [3/27] from: ammon:johnson:gmai:l at: 16-Dec-2004 13:37


I have also been annoyed by this. I know that I have used the result of reverse a time or two so it would undoubtedly break some of my code but it shouldn't break too much code. I vote that you fix it. ;-) Enjoy!! ~~Ammon ;~> On Thu, 16 Dec 2004 12:01:21 -0800, Carl <[carl--rebol--net]> wrote:
> I'm not sure if anyone has been annoyed by REVERSE returning > the tail position. I know I have. Everywhere I see REVERSE used
<<quoted lines omitted: 15>>
> To unsubscribe from the list, just send an email to rebol-request > at rebol.com with unsubscribe as the subject.
-- Enjoy!! ~~~ Ammon ~~~ ~ Sui Generis ~ ~~~~ ;~> ~~~~

 [4/27] from: hallvard:ystad:oops-as:no at: 16-Dec-2004 22:55


The word Hallvard Dixit Carl (21.01 16.12.2004):

 [5/27] from: Izkata:Comcast at: 16-Dec-2004 15:48


I'd personally say, change it. As long as it still changes the original series, my code won't be messed up, but any new stuff might be easier. (I feel like an idiot - I never thought of using 'head !)

 [6/27] from: greggirwin:mindspring at: 16-Dec-2004 14:52


YES! C> "Say the word, and it will be done by sundown today." The word. Even if I have code that breaks (which I doubt), I'm all for it. Should be OK when using /part too IMO. -- Gregg

 [7/27] from: AJMartin:orcon at: 21-Dec-2004 18:07


I've always written: head reverse Foo Carl, I'm for the change. --- Andrew Martin

 [8/27] from: james:mustard at: 21-Dec-2004 18:07


Indeed! Gregg Irwin wrote:

 [9/27] from: SunandaDH:aol at: 16-Dec-2004 17:19


Carl:
> But, that feature is rarely, > if ever, used (in REVERSE that is).
Found a few more examples -- none of them my code. make-dir -- in the current live version of REBOL (not in later betas) dragdrop.r -- one of the prototype new styles in IOS/Developer alerts.r -- one of Allen Kamp's utilities in IOS/Developer http://localhost/cgi-bin/view-script.r?script=exif-core.r -- script in the Library doing bitwise operations Other scripts in the Library including: -- opengl.r -- gpzip.r -- msdate-to-date.r -- oneliner-save-console-history.r -- rar.r So, it's not common, but it would break a load of code if changed, Sunanda.

 [10/27] from: hallvard:ystad:oops-as:no at: 16-Dec-2004 23:41


Dixit [SunandaDH--aol--com] (23.19 16.12.2004):
>http://localhost/cgi-bin/view-script.r?script=exif-core.r -- script in the >Library doing bitwise operations
And for those who don't have the whole script library mirrored on their local machines, the URL would be http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=exif-core..r :-) HY

 [11/27] from: SunandaDH:aol at: 16-Dec-2004 19:31


Thanks Hallvard,
> And for those who don't have the whole script library mirrored on their > local machines, the URL would be
I must try to pay attention to what I'm doing...... More evidence of use: I did a google search for rebol "head reverse" There are over 1800 matches. Not all unique scripts, of course. But a common enough idiom. Some matches on REBOL.com too. Try this google search: rebol "head reverse" site:www.rebol.com Sunanda.

 [12/27] from: ammon:johnson:gm:ail at: 16-Dec-2004 17:45


Head Reverse isn't what you should be looking for to see if it is going to break anything...
>> head head reverse "123"
== "321" The only scripts it is going to break are the ones that use Reverse WITHOUT Head... Enjoy!! ~~Ammon ;~> On Thu, 16 Dec 2004 19:31:56 EST, [SunandaDH--aol--com] <[SunandaDH--aol--com]> wrote:
> Thanks Hallvard, > > And for those who don't have the whole script library mirrored on their
<<quoted lines omitted: 11>>
> To unsubscribe from the list, just send an email to rebol-request > at rebol.com with unsubscribe as the subject.
-- Enjoy!! ~~~ Ammon ~~~ ~ Sui Generis ~ ~~~~ ;~> ~~~~

 [13/27] from: james:mustard at: 21-Dec-2004 18:07


A simple find/replace for "head reverse" to "reverse'" would fix those scripts. [SunandaDH--aol--com] wrote:

 [14/27] from: rebolforces:gm:ail at: 17-Dec-2004 11:47


I remember arguing for this change when reverse was first introduced. ;-) You provided an example at the time of wanting to keep it consistent with insert, unfortunately I can't find that example now. I use reverse a bit for manipulating face pane blocks, or for a reverse lookup list. Never found an occassion where I didn't want the head returned. I'm sure I'll finally find one the moment it is changed. :-) The current need to use head with reverse is not intuitive for most people the first time they encounter it. So I vote for the change. -- Allen On Thu, 16 Dec 2004 12:01:21 -0800, Carl <[carl--rebol--net]> wrote:

 [15/27] from: carl:cybercraft at: 21-Dec-2004 18:07


On Thursday, 16-December-2004 at 17:45:25 Ammon wrote,
>Head Reverse isn't what you should be looking for to see if it is >going to break anything... > >>> head head reverse "123" >== "321" > >The only scripts it is going to break are the ones that use Reverse >WITHOUT Head...
That's just what I was thinking. A few possibles... http://www.codeconscious.com/rebsite/rebol-library/scroll-panel.r http://www.rebol.com/view/reb/layout.r http://forsythe.agent-smith.net/calc.r I say possibles as I didn't look at the code closely to determine if the REVERSEs really were reversing a series. It's possible they may be working on tuples or pairs, or they may not be the default REVERSE. Oh - I'm in favour of the change. -- Carl Read.

 [16/27] from: lmecir:mbox:vol:cz at: 17-Dec-2004 8:02


<Sunanda> Typically something like: if user-display-option = "earliest first" [ data: head reverse data ] foreach item data [ .... ] Sadly, all that code would break. </Sunanda> <Sunanda> Found a few more examples -- none of them my code. make-dir -- in the current live version of REBOL (not in later betas) dragdrop.r -- one of the prototype new styles in IOS/Developer alerts.r -- one of Allen Kamp's utilities in IOS/Developer </Sunanda> <Ammon>
>Head Reverse isn't what you should be looking for to see if it is >going to break anything...
<<quoted lines omitted: 4>>
>The only scripts it is going to break are the ones that use Reverse >WITHOUT Head...
</Ammon> <James> A simple find/replace for "head reverse" to "reverse'" would fix those scripts. </James> <Ladislav> I vote *for* the change. As Ammon said, none of the examples will break, neither it can affect any of my code. </Ladislav>

 [17/27] from: lmecir:mbox:vol:cz at: 17-Dec-2004 8:14


Carl Read napsal(a):
>That's just what I was thinking. A few possibles... >http://www.codeconscious.com/rebsite/rebol-library/scroll-panel.r
<<quoted lines omitted: 3>>
>Oh - I'm in favour of the change. >-- Carl Read.
all those are safe -Ladislav

 [18/27] from: pwawood:mango:my at: 17-Dec-2004 20:26


Wouldn't a refinement, preferably with a short name, be a "safer" solution? Peter

 [19/27] from: rotenca:telvia:it at: 17-Dec-2004 14:26


I am not against the reverse change also if it breaks orthogonality. I want only to remember the /part refinement reverse/part [1 2 3] and ask: where is the head here? reverse next [1 2 3] -- Ciao Romano Paolo Tenca

 [20/27] from: greggirwin:mindspring at: 17-Dec-2004 11:30


Hi Romano, RPT> and ask: where is the head here? RPT> reverse next [1 2 3] I thought about this too. My feeling is that == [1 3 2] would be better than == [3 2] for consistency with the standard usage of HEAD REVERSE. I can certainly think of scenarios where the second option might be more useful, but I think 99% of the time we will be better served by the first. -- Gregg

 [21/27] from: greggirwin::mindspring::com at: 18-Dec-2004 10:20


This is a re-send of a message I sent to the list before, that never arrived. Hi Sunanda, Sac> make-dir -- in the current live version of REBOL (not in later betas) Sac> dragdrop.r -- one of the prototype new styles in IOS/Developer Sac> alerts.r -- one of Allen Kamp's utilities in IOS/Developer Sac> exif-core.r Sac> opengl.r Sac> gzip.r Sac> msdate-to-date.r Sac> oneliner-save-console-history.r Sac> rar.r Sac> So, it's not common, but it would break a load of code if changed, These all seem to use HEAD before REVERSE, so none of them should break; or am I missing something obvious? The change just makes the HEAD call redundant. I did a very quick-n-dirty rawk against about 6,000 files here, and I think the break count would be near-nil. Looks like Cal may be the only victim, in his old rem42 editor script. -- Gregg

 [22/27] from: hallvard::ystad::oops-as::no at: 19-Dec-2004 9:54


OK, folks, this is my third attempt at posting this email. Please excuse me if it appears thrice (I doubt that should happen, though). Hallvard Original message: It will not break, since head head "123" is identical to head "123" i.e. if 'reverse were to do 'head all by itself, performing an extra 'head on the series won't change anything. I haven't seen _any_ examples of 'reverse being used _without_ 'head (situations where scrips might actually break), as Carl pointed out in his post. Then there is the current inconsistency in 'reverse: tuples! and pairs! (since they are not series!) will not be "empty" after being reversed (see http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlHGYB).. And then there are lists! : reverse to-list [1 2 3] == make list! [1] head reverse to-list [1 2 3] == make list! [3 2 1] index? reverse [1 2 3] ; block == 4 index? reverse to-list [1 2 3] ; list == 3 An odd difference, if you ask me. Maybe this could be done more logical too, if 'reverse's behaviour were to change? HY On Thu, 16 Dec 2004 15:29:04 EST [SunandaDH--aol--com] wrote:

 [23/27] from: antonr::lexicon::net at: 20-Dec-2004 13:09


I vote *yes* for the change. As to Romano's question; given: next [1 2 3] ;== [2 3] then it makes sense to get this result: reverse next [1 2 3] ;== [3 2] Often, reverse is used with a variable: blk: [1 2 3] reverse blk ;== [3 2 1] In such a case, the index of the block *is preserved*, instead of "lost" (by going always to the tail). So, also: blk: next [1 2 3] reverse blk ;== [3 2] ; <--- index preserved head blk ;== [1 3 2] Anton.

 [24/27] from: hallvard:ystad-oops:as:no at: 17-Dec-2004 10:33


It will not break, since head head "123" is identical to head "123" i.e. if 'reverse were to do 'head all by itself, performing an extra 'head on the series won't change anything. I haven't seen _any_ examples of 'reverse being used _without_ 'head (situations where scrips might actually break), as Carl pointed out in his post. Then there is the current inconsistency in 'reverse: tuples! and pairs! (since they are not series!) will not be "empty" after being reversed (see http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlHGYB). And then there are lists! :
>> reverse to-list [1 2 3]
== make list! [1]
>> head reverse to-list [1 2 3]
== make list! [3 2 1]
>> index? reverse [1 2 3] ; block
== 4
>> index? reverse to-list [1 2 3] ; list
== 3 An odd difference, if you ask me. Maybe this could be done more logical too, if 'reverse's behaviour were to change? HY On Thu, 16 Dec 2004 15:29:04 EST SunandaDH-aol.com wrote:
>Carl: >> I'm not sure if anyone has been annoyed by REVERSE
<<quoted lines omitted: 19>>
>rebol-request >at rebol.com with unsubscribe as the subject.
Write here:

 [25/27] from: hallvard:ystad:oops-as:no at: 18-Dec-2004 19:24


Seems this never hit the list. I'll try again (even though most of this has been said by others already): On Fri, 17 Dec 2004 10:33:15 +0100 "Hallvard Ystad" <[hallvard--ystad--oops-as--no]> wrote:
>It will not break, since head head "123" >is identical to
<<quoted lines omitted: 59>>
>> >Write here:
Write here:

 [26/27] from: greggirwin:mindspring at: 16-Dec-2004 16:50


Hi Sunanda, Sac> make-dir -- in the current live version of REBOL (not in later betas) Sac> dragdrop.r -- one of the prototype new styles in IOS/Developer Sac> alerts.r -- one of Allen Kamp's utilities in IOS/Developer Sac> exif-core.r Sac> opengl.r Sac> gzip.r Sac> msdate-to-date.r Sac> oneliner-save-console-history.r Sac> rar.r Sac> So, it's not common, but it would break a load of code if changed, These all seem to use HEAD before REVERSE, so none of them should break; or am I missing something obvious? The change just makes the HEAD call redundant. I did a very quick-n-dirty rawk against about 6,000 files here, and I think the break count would be near-nil. Looks like Cal may be the only victim, in his old rem42 editor script. -- Gregg

 [27/27] from: lmecir:mbox:vol:cz at: 17-Dec-2004 13:57


PeterWAWood napsal(a):
>Wouldn't a refinement, preferably with a short name, be a "safer" solution? > >Peter >
As far as I am concerned, I prefer the solution proposed by Carl and think, that it is actually safer, because it follows "the principle of the least surprise". -Ladislav

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted