Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gilleain (9133)

gilleain
  (email not shown publicly)
+ -

  Comment: Re:object refcounting (Score 1) on 2010.04.22 10:27

by gilleain on 2010.04.22 10:27 (#71911)
Attached to: I can haz constant?
Doh. Yes, I didn't think that through really, did I?

I have never used static class variables in Java. They seem like a subtle disaster waiting to happen. Also I try (where possible) to program without side-effects.

Moreover, Java doesn't have proper destructors, so you can't decrease the count in any reasonable way.

Is there perhaps a more reasonable use case for a kind of object-level namespace? It would be horrible in practice, but something like public static HashMap MyBaseObject.OBJECT_VARIABLES...

Sounds like a guarantee of threading problems to me, though.
Read More 8 comments
Comments: 8
+ -

  Comment: object refcounting (Score 1) on 2010.04.22 10:08

by gilleain on 2010.04.22 10:08 (#71909)
Attached to: I can haz constant?
The only real (non car-based :) example I can remember seeing for static class variables is reference counting:

public class MyBaseObject {

    public static int REFCOUNT;

    public MyBaseObject() {
        REFCOUNT++;
    }
}

public class DerivedObject extends MyBaseObject {

    public DerivedObject() {
        super();
    }

    public static void main(String[] args) {
        for (int i = 0 ; i < 10; i++) {
            DerivedObject d = new DerivedObject();
            System.out.print(d.REFCOUNT + " ");
        }
    }
}

prints "1 2 3 4 5 6 7 8 9 10 " as you might expect.
Read More 8 comments
Comments: 8
+ -

  Comment: Very interesting (Score 1) on 2009.09.02 5:08

You know, if you swap the word "labyrinth" for "molecule" and "cell" for "atom" and "wall" for "bond"....

The whole flattening hierarchy approach also sounds a bit like a data structure I read about on wikipedia called a "disjoint-set forest" (link).

Anyway, it seems like the method works because labyrinths (and molecules!) have a restricted dimension. For labyrinths in 100 dimensions, the equivalence classes would have few members, and the complexity would again be closer to O(N^2). I guessing, of course :)

Read More 6 comments
Comments: 6
+ -

  Comment: Book : Beautiful Code (Score 1) on 2009.03.16 9:09

by gilleain on 2009.03.16 9:09 (#67815)
Attached to: Code reviews -- a manifesto

It's worth a read. Has chapters by various programmers 'of note' about stuff.

Well, about code. But it's like an exam essay where each coder has interpreted the question "what is beautiful code" in different ways.

Read More 8 comments
Comments: 8