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
Post your strangest loop and win (up to) 4 free passes to Strange Loop!
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 1 - 25 of 41 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
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
 
Alex  
View profile  
 More options Aug 3 2010, 8:09 am
From: Alex <alexdmil...@yahoo.com>
Date: Tue, 3 Aug 2010 05:09:00 -0700 (PDT)
Subject: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
The latest Java Posse episode (<a href="http://javaposse.com/
java_posse_317_newscast_for_july_29th_2010">#317</a>) features a short
segment (start around 51:45) of the posse talking about the <a
href="http://strangeloop2010.com">Strange Loop conference</a>.  The
Java Posse are giving away four FREE (as in beer) tickets based on a
contest.

The contest is:  "Write the strangest loop" (any language is ok).  You
should post your answer here and list the number (out of 4) you
possibly could use.  The answer will be judged by the posse (and
me!).

I'm not sure what the deadline for the contest will be but we'll post
that here.

Give us your loops!

Alex Miller


 
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.
Matt Passell  
View profile  
 More options Aug 3 2010, 12:51 pm
From: Matt Passell <mpass...@grovehillsoftware.com>
Date: Tue, 3 Aug 2010 09:51:27 -0700 (PDT)
Local: Tues, Aug 3 2010 12:51 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
If I were to win, I'd only need one ticket.  I'm not sure if this
counts (it might be more appropriate for the Daily WTF), but I once
saw Java code that looked like the following (I don't remember what
was inside the if blocks):

for (int i = 0; i < 4; i++) {
  if (i == 0) {
    //some code to handle case 0
  } else if (i == 1) {
    //some code to handle case 1
  } else if (i == 2) {
    //some code to handle case 2
  } else if (i == 3) {
    //some code to handle case 3
  } else if (i == 4) {
    //some code to handle case 4
  }

}

I was going to make fun of whoever had written it and ask why on earth
it had been structured as a loop, but I lost my nerve when the version
control system revealed that it had been written by the head of the
engineering team for the small startup I was at.  I think I'd be more
courageous about calling him on it at this point. :)

--Matt


 
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.
Alex  
View profile  
 More options Aug 3 2010, 1:23 pm
From: Alex <alexdmil...@yahoo.com>
Date: Tue, 3 Aug 2010 10:23:00 -0700 (PDT)
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
The deadline for the contest will be Aug. 31st!  Give us your loops!

Alex


 
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.
Vince O'Sullivan  
View profile  
 More options Aug 3 2010, 8:09 pm
From: "Vince O'Sullivan" <vjosulli...@gmail.com>
Date: Tue, 3 Aug 2010 17:09:51 -0700 (PDT)
Local: Tues, Aug 3 2010 8:09 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
for (Strange loop : loops)
    if (loop.isStrange())
        continue;

On Aug 3, 6:23 pm, Alex <alexdmil...@yahoo.com> wrote:


 
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.
Kevin Wright  
View profile  
 More options Aug 3 2010, 8:25 pm
From: Kevin Wright <kev.lee.wri...@gmail.com>
Date: Wed, 4 Aug 2010 01:25:02 +0100
Local: Tues, Aug 3 2010 8:25 pm
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

For wacky loop madness, it doesn't get much stranger than loop unrolling in
C/C++
So I present to you... <drum roll> ...Duff's Device!
(lifted direct from Wikipedia)

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);
        }}

Such elegance!
Such conciseness!

Why oh why did I ever allow Scala, with it's complexity and ugly, ugly
functional constructs to enter my life?
It's nothing but a virtuous life of clean, simple,
comprehensible imperative code for me from now on!

On 4 August 2010 01:09, Vince O'Sullivan <vjosulli...@gmail.com> wrote:

--
Kevin Wright

mail/google talk: kev.lee.wri...@gmail.com
wave: kev.lee.wri...@googlewave.com
skype: kev.lee.wright
twitter: @thecoda


 
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.
Joseph Darcy  
View profile  
 More options Aug 3 2010, 9:11 pm
From: Joseph Darcy <jdda...@gmail.com>
Date: Tue, 3 Aug 2010 18:11:46 -0700
Local: Tues, Aug 3 2010 9:11 pm
Subject: Re: [The Java Posse] Post your strangest loop and win (up to) 4 free passes to Strange Loop!

On Tue, Aug 3, 2010 at 5:09 AM, Alex <alexdmil...@yahoo.com> wrote:
> The latest Java Posse episode (<a href="http://javaposse.com/
> java_posse_317_newscast_for_july_29th_2010">#317</a>) features a short
> segment (start around 51:45) of the posse talking about the <a
> href="http://strangeloop2010.com">Strange Loop conference</a>.  The
> Java Posse are giving away four FREE (as in beer) tickets based on a
> contest.

> The contest is:  "Write the strangest loop" (any language is ok).  You
> should post your answer here and list the number (out of 4) you
> possibly could use.  The answer will be judged by the posse (and
> me!).

From many years ago when I was first getting into Java, I recall this
infinite Java loop pointed out by the Sumatra project
(http://www.cs.arizona.edu/projects/sumatra/hallofshame/):

while (true) {
    try {
        return;
    } finally {
        continue;
    }

}

-Joe
(2 passes)

 
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.
Mark Derricutt  
View profile  
 More options Aug 3 2010, 9:23 pm
From: Mark Derricutt <m...@talios.com>
Date: Wed, 4 Aug 2010 13:23:15 +1200
Local: Tues, Aug 3 2010 9:23 pm
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

Does this even compile?

As you have the do {} inside the first case statement, and all other case's
are inside the do.     Since there's not in scope of the case I'd expect
this to fail?   But then - I'm no C/C++ guy so who knows what wacky hackery
they get up to :)

--
Pull me down under...

On Wed, Aug 4, 2010 at 12:25 PM, Kevin Wright <kev.lee.wri...@gmail.com>wrote:


 
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.
Mac  
View profile  
 More options Aug 3 2010, 11:41 pm
From: Mac <wmacgy...@gmail.com>
Date: Tue, 3 Aug 2010 20:41:11 -0700 (PDT)
Local: Tues, Aug 3 2010 11:41 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
here is my entry

(defn pure-loop [n]
  (println "pure " n)
  (if (= n 0)
    0
    #(danger-loop (dec n))))

(defn danger-loop [n]
  (println "danger " n)
  (if (= n 0)
    0
    #(pure-loop (dec n))))

user=> (trampoline pure-loop 20)
pure  20
danger  19
pure  18
danger  17
pure  16
danger  15
pure  14
danger  13
pure  12
danger  11
pure  10
danger  9
pure  8
danger  7
pure  6
danger  5
pure  4
danger  3
pure  2
danger  1
pure  0

It's strange because, well, to use trampoline to do a decreasing loop
is very strange indeed.


 
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.
Kirk  
View profile  
 More options Aug 4 2010, 12:43 am
From: Kirk <kirk.pepperd...@gmail.com>
Date: Wed, 4 Aug 2010 06:43:51 +0200
Local: Wed, Aug 4 2010 12:43 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
I'll be speaking there so I don't need a pass but thought it might be fun to put in a puzzler.

public class StrangeLoop {
    public static void main(String[] args) {
        http://www.thestrangeloop.com
        do {
            System.out.println("Strange Loop");
            continue http;
        } while (false);
    }

}

Puzzler, infinite loop or normal termination?

Regards,
Kirk


 
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.
Mark Derricutt  
View profile  
 More options Aug 4 2010, 12:53 am
From: Mark Derricutt <m...@talios.com>
Date: Wed, 4 Aug 2010 16:53:37 +1200
Local: Wed, Aug 4 2010 12:53 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

Or a stack blowout?

Just having a discussion in the office about whether or not the continue
will leave a nested stack of do's in the stack..

--
Pull me down under...


 
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.
Kevin Wright  
View profile  
 More options Aug 4 2010, 5:01 am
From: Kevin Wright <kev.lee.wri...@gmail.com>
Date: Wed, 4 Aug 2010 10:01:18 +0100
Local: Wed, Aug 4 2010 5:01 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

my thinking:

`http:` is the label (followed by a comment that the pre-processor strips
out)
`do { ... } while (...)` is the labelled statement
`continue <label>` attempts to transfer control back to the "continue
target".  In this case, the labelled do/while loop

a `do {statement} while (expression)` loops will check its expression only
once the statement has executed normally (which it hasn't here)
So... the loop will begin again, and continue infinitely, or until an
exception is thrown or the JVM is terminated.

No stack involved, at the level of compiled machine code it'll be jump
instructions all the way down...

The language spec covering all this is here:
http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html
( or in pdf here:
http://java.sun.com/docs/books/jls/download/langspec-3.0.pdf )

For anyone still labouring under the delusion that Java is a simple
language, it's a heavyweight document; running to 650 pages in almost 8MB
but you only really need chapter 14 for this question :)

On 4 August 2010 05:43, Kirk <kirk.pepperd...@gmail.com> wrote:

--
Kevin Wright

mail/google talk: kev.lee.wri...@gmail.com
wave: kev.lee.wri...@googlewave.com
skype: kev.lee.wright
twitter: @thecoda


 
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.
Steven Siebert  
View profile  
 More options Aug 4 2010, 8:55 am
From: Steven Siebert <smsi...@gmail.com>
Date: Wed, 4 Aug 2010 08:55:50 -0400
Local: Wed, Aug 4 2010 8:55 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

I tried to go for a strange "Strange loop" (
http://en.wikipedia.org/wiki/Strange_loop)...but I ended up with a recursive
loop of doom.  Please forgive the quick thrown-together implementation =)

(2 passes, please =)

Given a "normal" string, this app would loop through and resolve the acronym
with the full break out and put the acronym in parenthesis after it.  Given
recursive acronyms, all hell breaks loose.

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Lets make that String understandable to management....
 */
public class Main {

    public static void main(String[] args) {

        //replace var test with cli/arg input
        String test = "In addition to java you can write plugins for the "
                + "GNU tool Nagios using PHP";
        while (AcronymFinder.hasAcronym(test)) {
            test = AcronymFinder.explodeAcronym(test);
            System.out.println(test);
        }
    }

    private static class AcronymFinder {

        private static Pattern p = Pattern.compile("([a-zA-Z]*)[\\s|\\.]");
        /**
         * Takes in a String and checks it against the acronym dictionary,
         * resolving any acronyms in the process
         *
         * @param raw
         * @return
         */
        public static String explodeAcronym(String raw) {
            String out = null;

            Matcher m = p.matcher(raw);

            StringBuilder sb = new StringBuilder();

            while (m.find()) {
                try {
                    Acronyms a = Acronyms.valueOf(m.group(1));
                    sb.append(a.resolve());
                    sb.append(" (" + m.group(1) + ")"); //the parens
prevents the acronym from getting picked up twice, due to regex impl
                } catch (IllegalArgumentException e) {
                    sb.append(m.group(1));
                }
                sb.append(" ");
            }
            if (sb.length() > 0) {
                out = sb.toString();
            } else {
                out = raw;
            }
            return out;
        }

        public static boolean hasAcronym(String raw) {
            Matcher m = p.matcher(raw);

            while (m.find()) {
                try {
                    Acronyms a = Acronyms.valueOf(m.group(1));
                    return true;
                } catch (IllegalArgumentException e) {
                }
            }
            return false;
        }
    }

    private enum Acronyms {

        GNU("GNU is Not Unix"),
        Nagios("Nagios Ain't Gonna Insist On Sainthood"),
        PHP("PHP Hypertext Preprocessor");
        private String full;

        private Acronyms(String f) {
            full = f;
        }

        public String resolve() {
            return full;
        }
    }

}

On Wed, Aug 4, 2010 at 5:01 AM, Kevin Wright <kev.lee.wri...@gmail.com>wrote:


 
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.
Discussion subject changed to "Post your strangest loop and win (up to) 4 free passes to Strange Loop!" by Fabrizio Giudici
Fabrizio Giudici  
View profile  
 More options Aug 4 2010, 9:06 am
From: Fabrizio Giudici <fabrizio.giud...@tidalwave.it>
Date: Wed, 04 Aug 2010 15:06:31 +0200
Local: Wed, Aug 4 2010 9:06 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/4/10 11:01 , Kevin Wright wrote:

> For anyone still labouring under the delusion that Java is a
> simple language, it's a heavyweight document; running to 650 pages
> in almost 8MB but you only really need chapter 14 for this question
> :)

Absolute figures are mostly worthless... comparisons help. How long
are the specs of Scala? Of course, I presume it might also depend on
the writing style.

- --
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio.Giud...@tidalwave.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxZZdYACgkQeDweFqgUGxcviQCbBSreTUXxWeVBlLjqqLfJSSWM
VY0AnjlJLJZt25fUTVnGVZIAyB+AsTAx
=j+FW
-----END PGP SIGNATURE-----


 
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.
Discussion subject changed to "Post your strangest loop and win (up to) 4 free passes to Strange Loop!" by Reinier Zwitserloot
Reinier Zwitserloot  
View profile  
 More options Aug 4 2010, 10:25 am
From: Reinier Zwitserloot <reini...@gmail.com>
Date: Wed, 4 Aug 2010 07:25:21 -0700 (PDT)
Local: Wed, Aug 4 2010 10:25 am
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
Yes, Mark, it does. C works in mysterious ways, and this is just one
in a long, possibly endless, procession of them. Duff's device is one
of those hallowed "WTF? Oh.. Ooooh! I get it! Whoever cooked this up
is an evil genius!!!" optimizations useful in the early days of
computing. The wikipedia page has a lengthy treatment on the topic,
but the basic mechanics behind why this is legal in C is this:

 1. A switch statement's body is simply like any other block, with as
any extra that you can shove any number of case statements in it.
 2. switch works by jumping to the right case statement.
 3. In C, you may jump right into the middle of a loop, without
breaking things.

Most folks would say that in java you can only jump out of LOOPS,
which explains why it doesn't work, but this isn't true. It doesn't
work in java because, switch blocks are defined as containing a 0-n
set of (case/default statement followed by 0-n statements), whereas in
C its defined as containing 0-n statements, and case/default are also
statements. You CAN in fact jump around indiscriminately in java code
and it works just fine. Behold this code:

foo: {
    System.out.print("Hello, ");
    if (0 < System.currentTimeMillis()) break foo;
    System.out.println("World!");
    System.exit(0);

}

System.out.println("Universe!");

which will print "Hello, Universe!" if your system clock is set later
than Jan 1st, 1970, and causes no compilation problems at all. This
indiscriminate breaking out of any code block, not just those
representing loops, is in fact a holdover from C, where 'break' in a
switch statement, which was after all defined just as a glorified goto
form, required this. In java this isn't necessary (switch being
differently defined), but nevertheless you can break out of whatever
you want, loop or no.

Which, I guess, is my entry for 'strange loop': It's so strange, one
could argue it's not a loop at all!

NB: I don't need a ticket, I can't make the date, but I couldn't
resist :P

On Aug 4, 3:23 am, Mark Derricutt <m...@talios.com> wrote:


 
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.
Reinier Zwitserloot  
View profile  
 More options Aug 4 2010, 10:26 am
From: Reinier Zwitserloot <reini...@gmail.com>
Date: Wed, 4 Aug 2010 07:26:12 -0700 (PDT)
Local: Wed, Aug 4 2010 10:26 am
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
I really like how folks keep making the argument that java sucks
because it is well documented. Only a scala fanboy would go that far.

</trollbait>

On Aug 4, 11:01 am, Kevin Wright <kev.lee.wri...@gmail.com> wrote:


 
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.
Viktor Klang  
View profile  
 More options Aug 4 2010, 10:57 am
From: Viktor Klang <viktor.kl...@gmail.com>
Date: Wed, 4 Aug 2010 16:57:42 +0200
Local: Wed, Aug 4 2010 10:57 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

On Wed, Aug 4, 2010 at 4:26 PM, Reinier Zwitserloot <reini...@gmail.com>wrote:

> I really like how folks keep making the argument that java sucks
> because it is *well documented*.

That made me laugh. What an euphemism! :D

--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang


 
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.
Robert Casto  
View profile  
 More options Aug 4 2010, 11:06 am
From: Robert Casto <casto.rob...@gmail.com>
Date: Wed, 4 Aug 2010 11:06:13 -0400
Local: Wed, Aug 4 2010 11:06 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

Going back to what this thread is about, you could post a better strange
loop or...

Sign up to be a volunteer. They are looking for 8-10 people to help out.

http://strangeloop2010.com/pages/volunteers

On Wed, Aug 4, 2010 at 10:57 AM, Viktor Klang <viktor.kl...@gmail.com>wrote:

--
Robert Casto
www.robertcasto.com

 
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.
Kevin Wright  
View profile  
 More options Aug 4 2010, 11:09 am
From: Kevin Wright <kev.lee.wri...@gmail.com>
Date: Wed, 4 Aug 2010 16:09:46 +0100
Local: Wed, Aug 4 2010 11:09 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

I actually got the numbers wrong here. although the final page has 649
printed on it, acrobat informs me that the document is in fact 684 pages
long,

Java (3rd Edition): 684 pages, 7932 KB
Scala (current in trunk): 191 pages, 1312 KB

Why would this be so? I can think of a few reasons:

   - Java has had longer to discover and document ambiguities
   - The Java spec contains more "boilerplate": copyright, legal notices,
   padding, whitespace, etc.
   - Much of what Java considers to be part of the Language in Java is
   library in Scala (and so out of scope for the spec)
   e.g. enums, while loops, break/continue
   - Java has *lots* of special cases that Scala does away with
   e.g. autoboxing, + operator on strings, etc.

Truth be told, it's probably all of the above...

On 4 August 2010 14:06, Fabrizio Giudici <fabrizio.giud...@tidalwave.it>wrote:

--
Kevin Wright

mail/google talk: kev.lee.wri...@gmail.com
wave: kev.lee.wri...@googlewave.com
skype: kev.lee.wright
twitter: @thecoda


 
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.
Discussion subject changed to "Java vs Scala specs was Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!" by Fabrizio Giudici
Fabrizio Giudici  
View profile  
 More options Aug 4 2010, 1:16 pm
From: Fabrizio Giudici <fabrizio.giud...@tidalwave.it>
Date: Wed, 04 Aug 2010 19:16:01 +0200
Local: Wed, Aug 4 2010 1:16 pm
Subject: Java vs Scala specs was Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/4/10 17:09 , Kevin Wright wrote:

Also, I'd say that Sun intention was to allow others to independently
implement the compiler (as IBM did), and in this case I presume you
have to be pretty picky. I think there's only a single Scala compiler
around, right?

- --
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio.Giud...@tidalwave.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxZoFEACgkQeDweFqgUGxd1kACeMa5OLnib0s4JR48+XU2IiB2W
orgAn16IQ4IDXwLe3t7ESlWKSjBBYEcg
=WwvA
-----END PGP SIGNATURE-----


 
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.
Discussion subject changed to "Java vs Scala specs was Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!" by Kevin Wright
Kevin Wright  
View profile  
 More options Aug 4 2010, 1:31 pm
From: Kevin Wright <kev.lee.wri...@gmail.com>
Date: Wed, 4 Aug 2010 18:31:46 +0100
Local: Wed, Aug 4 2010 1:31 pm
Subject: Re: Java vs Scala specs was Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

Right :)

Unlike the original Java, it's open source - so if anyone wanted to add
features to scalac, they'd be more likely to fork it than to start from
scratch working against the spec.
Even that is highly unlikely because:

   1. scalac has a plugin mechanism for extending/changing functionality
   2. Scala offers some quite nice techniques for you to add functionality
   via libraries, without requiring dedicated compiler support.
   Just take a look at actors (http://www.scala-lang.org/node/242)
   or ScalaTest(http://www.scalatest.org/quick_start),
   that's all library...

On 4 August 2010 18:16, Fabrizio Giudici <fabrizio.giud...@tidalwave.it>wrote:

--
Kevin Wright

mail/google talk: kev.lee.wri...@gmail.com
wave: kev.lee.wri...@googlewave.com
skype: kev.lee.wright
twitter: @thecoda


 
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.
Discussion subject changed to "Post your strangest loop and win (up to) 4 free passes to Strange Loop!" by Dominic Mitchell
Dominic Mitchell  
View profile  
 More options Aug 4 2010, 4:17 am
From: Dominic Mitchell <d...@happygiraffe.net>
Date: Wed, 4 Aug 2010 09:17:49 +0100
Local: Wed, Aug 4 2010 4:17 am
Subject: Re: [The Java Posse] Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!

On Tue, Aug 3, 2010 at 6:23 PM, Alex <alexdmil...@yahoo.com> wrote:
> The deadline for the contest will be Aug. 31st!  Give us your loops!

Sadly, I can't take credit for it, but I noticed this gem fly through my
feed reader this morning.

http://www.daemonology.net/blog/2010-08-02-neverending-finite-loop.html

The (C) loop in question is:

char i,x[99];for(x[98]=i=1;x[98];i++)i*=!++x[i]

-Dom


 
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.
Quoll  
View profile  
 More options Aug 4 2010, 12:20 pm
From: Quoll <gea...@gmail.com>
Date: Wed, 4 Aug 2010 09:20:32 -0700 (PDT)
Local: Wed, Aug 4 2010 12:20 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
Well if "famous" loops that we're not writing ourselves are being
mentioned (eg. Duff's Device) then how could I not mention the loop
written by Mel Kaye on the RPC-4000?

For those not familiar with the story, see: http://catb.org/jargon/html/story-of-mel.html

Kaye wrote a loop that had no termination condition, yet it terminated
just fine. He'd taken advantage of the fact that the address and
opcode were both part of the instruction word. His loop executed an
instruction that operated on data pointed to by the address operand,
then incremented the address before looping back to execute the same
instruction again on the new data location. The data had been placed
at the top of memory, so the address would overflow when he did his
final increment. The overflow incremented the opcode, changing it to a
"jump". Since the address operand had just overflowed, it was now set
to 0, and the process jumped to address 0 where it continued
execution. (This was obviously before page guards)  :-)

I'd love to write something that could challenge this piece of insane
genius, but modern languages tend to protect us from ourselves. It's
not impossible to see crazy stuff like this, but it's much rarer.

Paul Gearon


 
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.
Scott Bale  
View profile  
 More options Aug 4 2010, 1:05 pm
From: Scott Bale <drbceb-t...@yahoo.com>
Date: Wed, 4 Aug 2010 10:05:12 -0700 (PDT)
Local: Wed, Aug 4 2010 1:05 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
I once got "bit by byte" in the following loop:

for(byte a=Byte.MIN_VALUE; a<=Byte.MAX_VALUE; a++) {
  for(byte b=Byte.MIN_VALUE; b<=Byte.MAX_VALUE; b++) {
    byte[] test = new byte[] { a, b};
    //do something...
  }

}

When I ran this, CPU shot to 100% and I had to take down Eclipse with
extreme prejudice. Can you spot the problem?

The problem is, neither of the loops can terminate. Neither for
condition will ever become false and cause the loop to terminate,
because neither a nor b can ever grow larger than Byte.MAX_VALUE. Duh.


 
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.
Kyle Renfro  
View profile  
 More options Aug 4 2010, 3:43 pm
From: Kyle Renfro <kyleren...@gmail.com>
Date: Wed, 4 Aug 2010 12:43:28 -0700 (PDT)
Local: Wed, Aug 4 2010 3:43 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
Great contest!
1 pass required.

Here is a very handy loop that *everyone* should use. ha ha.

import java.io.*;
import java.util.logging.*;

public class AddTabs {

    public static void main(String[] args){

        try {
            BufferedReader in = new BufferedReader(new
InputStreamReader(System.in));
            PrintWriter out = new PrintWriter(new
OutputStreamWriter(System.out));
            String s = in.readLine();
            while (s != null){
                out.println(s.replaceAll("    ", "\t"));
                s = in.readLine();
            }
            in.close();
            out.close();
        }
        catch (IOException ex) {

Logger.getLogger(AddTabs.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


 
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.
Quoll  
View profile  
 More options Aug 4 2010, 9:15 pm
From: Quoll <gea...@gmail.com>
Date: Wed, 4 Aug 2010 18:15:19 -0700 (PDT)
Local: Wed, Aug 4 2010 9:15 pm
Subject: Re: Post your strangest loop and win (up to) 4 free passes to Strange Loop!
On Aug 4, 1:05 pm, Scott Bale <drbceb-t...@yahoo.com> wrote:

Ouch, that brings back an old memory too. In my case I was using an
int, but casting to a byte (for bit-banging purposes) and failed to
see that my comparison was occurring while in byte form... leading to
exactly this problem. I thought I was safe by using an int, but
obviously incompetence can overcome any level of protection. (I mean
mine here, not yours!)

Paul


 
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.
Messages 1 - 25 of 41   Newer >
« Back to Discussions « Newer topic     Older topic »