Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

The x-Done Loop

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-07 7:58

This is a construct that is very useful to avoid either a redundant check or a goto. This...
for(a;b;c) {
 expr1;
 if(d) {
  expr4;
  goto done;
 }
 expr2;
}
 expr3;
done:

...becomes...
for(a;b;c) {
 expr1;
 if(d) {
  expr4;
  break;
 }
 expr2;
} done {
 expr3;
}


where the intent is for statements in a done clause immediately following a loop to be executed if and only if the loop was exited via its termination condition being reached. This also generalises for while() and do-while, here using some common examples.

while(*j) {
 if(*j++ == k) {
  u = v + k;
  break;
 }
} done
 u = v - k;


do {
 if(f(a[i]))
  break;
} while(a[i++]) done {
 g();
}


Discuss.

Name: Anonymous 2013-01-07 8:00

So, like a finally except for conditional statements? Sounds interesting.

Now let's get Google to implement it in Go.

Name: Anonymous 2013-01-07 8:00

do while considered harmful.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-07 8:01

This is very useful for writing array searches and the like, as otherwise you either have to check for notfound/loop terminated a second time (stupid) or use a goto (which pisses off the purists).

Name: Anonymous 2013-01-07 8:02

>>4
People who don't know the length of an array beforehand should be lined up and shot O(n) times.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-07 8:04

>>2
It's the exact opposite, finally is always executed.

For symmetry I suppose you could have a done-else:

while(*j) {
 if(*j++ == k)
  break;
} done
 u = v - k;
else
 u = v + k;


But this is starting to obscure the flow even more than goto, so...

Name: Anonymous 2013-01-07 8:05

>>1
C/C++: anal acrobatics every day. Proven by Cudder!

Name: Anonymous 2013-01-07 8:08

>>5
What if the problem requires me to append stuff into the array while looping through it.

Name: Anonymous 2013-01-07 8:09

>>1
Any sufficiently complicated C or Fortran program contains an ad hoc informally-specified bug-ridden slow implementation of half of Common Lisp. -- Greenspun's Tenth Rule

Name: Anonymous 2013-01-07 8:10

Any language that doesn't let me define more syntax is shit.

Name: Anonymous 2013-01-07 8:11

>>9
http://www.apl.jhu.edu/~hall/Lisp-Notes/Loop-Summary.html
FINALLY specifies what to do once the LOOP form is done, usually used to specify a return value.

Name: Anonymous 2013-01-07 8:47

TURBO C QUALITY

Name: Anonymous 2013-01-07 9:20

There's nothing wrong with goto as a tool and it's only the shit-eating fuckstains, lapping up every bit of ethos they can and mindlessly spewing the same fetid, putrid nonsense without actually thinking about it, who actually think a language construct (that compiles to the same machine code as everything else) could ever possibly be a problem. Fuck their shitty fucking shit.

Name: Anonymous 2013-01-07 9:26

>>13
I wish C had JMP

Name: Anonymous 2013-01-07 11:19

>>14
C has setjmp(3) and longjmp(3)

Name: Anonymous 2013-01-07 11:47

doesn't matter, by the time someone gets their thumb outta their ass to implement something we'll all be dead

Name: Anonymous 2013-01-07 12:19

Why aren't you using Lisp, Cudder-sama?

Name: Anonymous 2013-01-07 12:27

>>15

But it behaves  more like delimited continuations.

Name: Anonymous 2013-01-07 12:30

>>15
setcontext / getcontext are more useful and more stable across various platforms.

Name: Anonymous 2013-01-07 12:32

>>17
C is faster.

Name: Anonymous 2013-01-07 20:21

>>19
Excluding Windows, of course.

Name: Anonymous 2013-01-08 4:21

Back to the front page you go!

Name: Anonymous 2013-01-08 5:39

>>4
int *searchuranus(const int *A, size_t n, int v)
{
    while (n--)
        if (*A++ == v)
            return (int *) A - 1;
    return 0;
}

Right in the Cudder.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-08 6:07

>>17
Lisp is like a drug; fun to get high on, not good for actual work.

>>23
I don't want to return. I want to continue immediately after that.

Name: Anonymous 2013-01-08 6:14

>>24
not good for actual work.
I.e. your jewish boss disallows you to use it, slave. Go lick another Jewish asshole, shabbos goy.

Name: Anonymous 2013-01-08 6:16

>>20
Just use Lisp-machine, which has hardware for dynamic type dispatch.

Name: Anonymous 2013-01-08 6:40

>>24
do {
    if (!n--)
        return;
} while (*A++ != v);
A--;
lalalalalalala;

Name: Anonymous 2013-01-08 6:43

>>24
if ((ptr = searchuranus(array, sizeof array / sizeof array[0], 69))) lalalalalalala;

Name: Anonymous 2013-01-08 7:20

>>24
not good for actual work.
What does that mean? It's turing-complete isn't it? It's not easy to compose code to achieve complex behaviour that's easy to maintain?

Name: Anonymous 2013-01-08 7:20

>>24
not good for actual work.
What does that mean? It's turing-complete isn't it? It's not easy to compose code to achieve complex behaviour that's easy to maintain?

Name: Anonymous 2013-01-08 8:35

>>30
Cudder, stop double-posting.

Name: Anonymous 2013-01-08 9:07

Cudder is sitting on a dildo

Name: Anonymous 2013-01-08 10:06

Adding a new control flow construct (especially one with shitty semantics) is way worse than using goto.

Name: Anonymous 2013-01-08 12:40

Someone implement this with a Scheme macro that uses call/cc.

Name: Anonymous 2013-01-08 13:25


require 'continuation'

callcc do |goto|
  for i in 0...5
    goto.call if i == 3
    puts i
  end
end
puts 'jevvs'

Name: Anonymous 2013-01-08 14:47

1-space of indentation

Name: Anonymous 2013-01-08 15:53

MARRY ME CUDDER-KUN!

Name: Anonymous 2013-01-08 15:55

>>37
s/KUN/様/

Name: Anonymous 2013-01-09 1:47

>>24
Lisp is like a drug; fun to get high on, not good for actual work.
While lisp is like a drug, and is fun to get high on, it is also good for actual work. Just look at this thread. The implementation of this new syntax is a trivial exercise in lisp. You wouldn't need to convince anyone or any compiler writers to adopt it, you could just implement it as a macro and include it in your project. And it would be portable too, since the macro would work on any compiler that implements the language. But then other people would need to read your new syntax. List itself isn't comparable to C however. There are too many features. It's too challenging to write an optimizing compiler, and C has advantages in enforcing resource use at the language level. A Lisp dialect that is essentially C in an ast would work, but when you throw static types into lisp the parentheses become a little overwhelming, at least more overwhelming than the semi colons and commas in C. If the macros in C could traverse and manipulate C's ast, then you would have no problems. All that's needed for this is a standard grammar for C compilers to follow and it can be exposed.

I don't want to return. I want to continue immediately after that.
An inline function would do the trick.

Name: Anonymous 2013-01-09 2:59

>>37
Cudder or Culver? Pick your poison.

Name: Anonymous 2013-01-09 3:00

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-09 8:08

>>36
One is enough.

Name: Anonymous 2013-01-09 9:38

It would be great if Cudder killed himself out of 4chan forever.

Name: Anonymous 2013-01-09 13:50

>>40
Culver easily, even though she supports kike languages (FIOC, javashit), that can be easily ignored. Cudder's rabid fanboy support of kike chip architecture on the otherhand is seriously harmful, also unacceptable.

Name: Anonymous 2013-01-09 14:06

>>43,44
I agree.

Name: Anonymous 2013-01-09 14:09

>>43
*herself

Also fuck you she's my platonic love

Name: Anonymous 2013-01-09 14:33

>>46
Fuck you, I saw her first.
I don't want platonic love I want to pump her ass full of cum while she declaims the Intel manuals and then we shall take a romantic walk on the Nevskaya Perspektiva and do some shopping.

Name: Anonymous 2013-01-09 14:40

>>46,47
Here's Cudder: http://pigroll.com/img/14-f-cali.jpg

He used to pretend he was three different girls. That was more pathetic than I thought possible.

I miss the old /prog/.

Name: Anonymous 2013-01-09 14:43

>>48
He used to pretend he was three different girls.
He even had a car accident with two of them, in Osaka.

Name: Anonymous 2013-01-09 14:45

>>48
I AM NOT CLICKING ON THAT LINK, FAGSHIT!

Name: Anonymous 2013-01-09 14:45

>>48
e/b/in pic, reddit/b/ro

Name: Anonymous 2013-01-10 6:38

>>35

Why such a poor choice of operator? call/CC is less primitive and less powerful then shift and reset. If you want callCC you can implement it with shift and reset.

I am going to puke over Jesus now.

Name: Anonymous 2013-01-10 7:15

>>52
You can implement shift and reset with call/cc as well.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-10 7:31

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-10 7:31

Name: 27,28 2013-01-10 8:42

>>54,55
How so? I'd say it's far cleaner to write a separate function like 'searchuranus' then branch depending on its return value, rather than using what you've proposed. Performing an extra comparison on a null pointer really isn't a huge issue, especially with high level languages where clarity and the use of idiomatic forms is far more important than unnoticeable performance gains. If you run a large program through a profiler and find that it performs poorly, chances are it's because an inefficient data structure was used, rather than using two comparisons where one would have been sufficient.

Name: Anonymous 2013-01-10 8:43

>>53
They are equally powerful? Can I haz paper?

Name: Anonymous 2013-01-10 12:55

>>54,55
Are you frustrated that you keep double-posting?

Name: Anonymous 2013-01-10 17:14

>>54-55
Is it true that you were 3 girls, Cudder?
Will one of them marry me?

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-11 4:35

>>58
Does this board have transactional semantics? What happened to the A in ACID?

>>59
I am a middle-aged woman. Not single.

Name: Anonymous 2013-01-11 19:49

>>60
Are you in a lesbian relationship with FFP?

Name: Anonymous 2013-01-11 20:06

>>60
I knew you were not single. I still have a crush on you.

Name: Anonymous 2013-01-11 20:08

>>60 oh wow, i thought that was just made up. So it's not Mr Satori at all, then, Mrs Atari..? and there is hope for /prog/ yet.... ;)

Name: Anonymous 2013-01-11 21:28

>>60
please tell us more about yourself.

Name: Anonymous 2013-01-11 21:57

>>60
lol, married? Are you fucking stupid? What's next, you drink socially and have a facebook?

Name: Anonymous 2013-01-11 22:06

>>65
Poor wretch.

Name: Anonymous 2013-01-11 22:29

>>66
Yeah, poor Cudder.

Name: Anonymous 2013-01-12 0:08

>>60
when did you have your operation then?

Name: Anonymous 2013-01-12 4:19

I wonder if cudder is polygamist relationship.

Name: Anonymous 2013-01-12 4:37

She has that tremendous capacity to ignore trolls and ad hominem.

Name: Anonymous 2013-01-12 7:26

>>53
Yes but you  need a mutable cell.

Name: tes !.CzKQna1OU!+59SbFBssi+M3ze 2013-01-12 10:39

test, spam me if you like

Name: test !7Q.NlmUoQE!a7Six4EVOK+5ROE 2013-01-12 10:41

bah

Name: testi !.CzKQna1OU!rcLUYFQ2lh0BTtk 2013-01-12 10:42

last one, i dare.

Name: Anonymous 2013-01-12 12:31

>>40
Cunter

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-01-13 6:36

>>63
Commodore > Atari

>>56
Every little bit counts.

Name: Anonymous 2013-01-13 7:04

Every little dubs counts

Name: Anonymous 2013-05-20 18:34


Don't change these.
Name: Email:
Entire Thread Thread List