Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
computed goto
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 36 of 36 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Frode V. Fjeld  
View profile  
 More options Aug 11 2012, 3:00 pm
Newsgroups: comp.lang.lisp
From: "Frode V. Fjeld" <frod...@gmail.com>
Date: Sat, 11 Aug 2012 21:00:37 +0200
Local: Sat, Aug 11 2012 3:00 pm
Subject: Re: computed goto

Bernd Nawothnig <Bernd.Nawoth...@t-online.de> writes:
> If somebody thinks he needs a goto he should better use a language
> which already comes with that construct (like C/C++).

As does Common Lisp, so what is your point?

--
Frode V. Fjeld


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zermelo  
View profile  
 More options Aug 11 2012, 3:02 pm
Newsgroups: comp.lang.lisp
From: Zermelo <zerm...@teletu.it.nospam.invalid>
Date: Sat, 11 Aug 2012 21:02:37 +0200
Local: Sat, Aug 11 2012 3:02 pm
Subject: Re: computed goto

RG <rNOSPA...@flownet.com> writes:
> You can also make an array of function pointers and do:

> *array[index]()

This is a nice trick, but you cannot jump inside another scope in this
way.
E.g. you cannot write code like this

<my goto-substitute with function pointers> label1;
<stuff...>
while (test) {
label1:
<other stuff>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Helmut Eller  
View profile  
 More options Aug 11 2012, 3:06 pm
Newsgroups: comp.lang.lisp
From: Helmut Eller <eller.hel...@gmail.com>
Date: Sat, 11 Aug 2012 21:06:36 +0200
Local: Sat, Aug 11 2012 3:06 pm
Subject: Re: computed goto

On Sat, Aug 11 2012, RG wrote:
> In article <46551c33-9db1-49e6-a0bc-4ab53b2fa05c@googlegroups.com>,
>  Bill <schottsta...@gmail.com> wrote:

>> > C/C++ doesn t have a native computed goto.

>> gnu c does, but in my experience it is not much, if any,
>> faster than a switch statement.

> That's because a  switch statement compiles to a computed goto.

Well, a switch statement needs to perform a range check first, then look
up the address in a table, then perform the computed goto.  Computed
gotos should be a win if the indirection through the table can be
avoided.

Helmut


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal J. Bourguignon  
View profile  
 More options Aug 11 2012, 3:19 pm
Newsgroups: comp.lang.lisp
From: "Pascal J. Bourguignon" <p...@informatimago.com>
Date: Sat, 11 Aug 2012 21:19:55 +0200
Local: Sat, Aug 11 2012 3:19 pm
Subject: Re: computed goto

That's ludicruous!  In a language where the Duff device is valid,
there's no reason to prevent jumping into or out of loops.

Duff device:

    send(to, from, count)
    register short *to, *from;
    register count;
    {
            register n = (count + 7) / 8;
            switch(count % 8) {
            case 0: do {    *to = *from++;
            case 7:         *to = *from++;
            case 6:         *to = *from++;
            case 5:         *to = *from++;
            case 4:         *to = *from++;
            case 3:         *to = *from++;
            case 2:         *to = *from++;
            case 1:         *to = *from++;
                       } while(--n > 0);
            }
    }

What an horror!  (But there's no difference between this code and yours).

--
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bernd Nawothnig  
View profile  
 More options Aug 11 2012, 3:27 pm
Newsgroups: comp.lang.lisp
From: Bernd Nawothnig <Bernd.Nawoth...@t-online.de>
Date: Sat, 11 Aug 2012 21:27:06 +0200
Local: Sat, Aug 11 2012 3:27 pm
Subject: Re: computed goto
On 2012-08-11, Helmut Eller wrote:

> On Sat, Aug 11 2012, RG wrote:

>> In article <46551c33-9db1-49e6-a0bc-4ab53b2fa05c@googlegroups.com>,
>>  Bill <schottsta...@gmail.com> wrote:

>>> > C/C++ doesn t have a native computed goto.

>>> gnu c does, but in my experience it is not much, if any,
>>> faster than a switch statement.

>> That's because a  switch statement compiles to a computed goto.

> Well, a switch statement needs to perform a range check first, then look
> up the address in a table, then perform the computed goto.

Not necessarily. The compiler knows all case constants and if they are
close enough a table of addresses is generated and only one
range-check at the beginning is needed. And if it is a byte-variable
even that check can be omitted. As far as I know uses the Python
runtime interpreter when compiled with a newer gcc this feature for a
significant speed up when switching by the byte-opcode.

> Computed gotos should be a win if the indirection through the table
> can be avoided.

Depends on the CPU and cache size how much that indirection costs. For
modern CPUs it should be neglectable.

Bernd

--
"Die Antisemiten vergeben es den Juden nicht, dass die Juden Geist
haben - und Geld." [Friedrich Nietzsche]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bernd Nawothnig  
View profile  
 More options Aug 11 2012, 3:37 pm
Newsgroups: comp.lang.lisp
From: Bernd Nawothnig <Bernd.Nawoth...@t-online.de>
Date: Sat, 11 Aug 2012 21:37:59 +0200
Local: Sat, Aug 11 2012 3:37 pm
Subject: Re: computed goto
On 2012-08-11, Pascal J. Bourguignon wrote:

Yeah, that is a jump into the do-while-loop. But what will happen if
there are local variables declared inside the loop?

> What an horror!

Indeed. A very ugly example for source code optimization. I think
(hope) modern compilers will do the above automatically (which should
be possible).

> (But there's no difference between this code and yours).

Correct.

Bernd

--
"Die Antisemiten vergeben es den Juden nicht, dass die Juden Geist
haben - und Geld." [Friedrich Nietzsche]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Helmut Eller  
View profile  
 More options Aug 12 2012, 2:44 am
Newsgroups: comp.lang.lisp
From: Helmut Eller <eller.hel...@gmail.com>
Date: Sun, 12 Aug 2012 08:44:07 +0200
Local: Sun, Aug 12 2012 2:44 am
Subject: Re: computed goto

On Sat, Aug 11 2012, Bernd Nawothnig wrote:
>> Computed gotos should be a win if the indirection through the table
>> can be avoided.

> Depends on the CPU and cache size how much that indirection costs. For
> modern CPUs it should be neglectable.

A memory reference will always be slower than no memory reference
regardless of cache sizes.

Helmut


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bernd Nawothnig  
View profile  
 More options Aug 12 2012, 5:04 am
Newsgroups: comp.lang.lisp
From: Bernd Nawothnig <Bernd.Nawoth...@t-online.de>
Date: Sun, 12 Aug 2012 11:04:56 +0200
Local: Sun, Aug 12 2012 5:04 am
Subject: Re: computed goto
On 2012-08-12, Helmut Eller wrote:

>> Depends on the CPU and cache size how much that indirection costs. For
>> modern CPUs it should be neglectable.

> A memory reference will always be slower than no memory reference
> regardless of cache sizes.

If the whole vector fits into L1 the cache - and that will be the case
if it is relatively small, e.g. 256 entries - accessing the address
will be very fast. No external bus cycles are required. So the
additional costs in such a situation will be neglectable or even zero
in some cases. Precondition for that is, of course, that the vector is
kept in the L1 cache and will stay there. But that will be
automatically the case if the corresponding switch/case is executed
often enough (like in the inner loop of the mentioned Python runtime
interpreter).

Bernd

--
"Die Antisemiten vergeben es den Juden nicht, dass die Juden Geist
haben - und Geld." [Friedrich Nietzsche]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zermelo  
View profile  
 More options Aug 12 2012, 5:19 am
Newsgroups: comp.lang.lisp
From: Zermelo <zerm...@teletu.it.nospam.invalid>
Date: Sun, 12 Aug 2012 11:19:30 +0200
Local: Sun, Aug 12 2012 5:19 am
Subject: Re: computed goto
"Pascal J. Bourguignon" <p...@informatimago.com> writes:

> That's ludicruous!  In a language where the Duff device is valid,
> there's no reason to prevent jumping into or out of loops.

I know you can jump into a loop. As a matter of fact that is exactly the
situation where you need a brute-force goto, because if you adhere
strictly to the structured programming tenets you will need a lot of
awkward flags.  

But the point I was replying to was another: if you can
simulate a jumping-into-a-scope goto using only an array of
pointers. And that is not possible, as far as I know (obviously that
question is little pertinent with lisp programming...)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Neuss  
View profile  
 More options Aug 14 2012, 4:42 am
Newsgroups: comp.lang.lisp
From: Nicolas Neuss <lastn...@scipolis.de>
Date: Tue, 14 Aug 2012 10:42:32 +0200
Local: Tues, Aug 14 2012 4:42 am
Subject: Re: computed goto

Bernd Nawothnig <Bernd.Nawoth...@t-online.de> writes:
> You can be very sure that I would get another answer for the same
> question in the C++ group ;-)

The difference being that many people here in c.l.l. know C++ reasonably
well, whereas in the C++ group almost no one knows anything about Common
Lisp.

Nicolas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tar...@google.com  
View profile  
 More options Aug 14 2012, 4:48 pm
Newsgroups: comp.lang.lisp
From: tar...@google.com
Date: Tue, 14 Aug 2012 13:48:15 -0700 (PDT)
Local: Tues, Aug 14 2012 4:48 pm
Subject: Re: computed goto
Any reason you can't just use CASE?
Or do you need to have the ability to "fall through" cases?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »