« first day (991 days earlier)      last day (3952 days later) » 

11:00 PM
I know why singletons are bad. I'm just wondering if it's still called a "singleton", if that instance is immutable - IOW, doesn't have those problematic properties.
*aside from the initial initialization.
 
watch it :D
 
@Mysticial single imutable instance - const?
 
@EvgenyPanasyuk Correct. Once instantiated, it can never be modified. Whole thing is const.
 
@Mysticial That sounds Ok.
 
Yeah. Aside from the initialization, I don't see what can go wrong.
 
11:03 PM
@Mysticial I remember that singleton initialization problems are discussed at Modern C++ book.
 
The idea here is that there's an abstract class, and multiple singleton subclasses that are immutable. The whole point is that they implement the virtual functions differently.
I'm not sure what kind of pattern this is.
 
user142019
 
user142019
This one is fun too.
 
11:24 PM
ITT: countries are not countries. they're islands
 
How do I get the wikidot password?
 
user142019
You guess it.
 
@MonadNewb What is "the" wikidot password?
 
you get it if you are special.
 
@DeadMG I'm special! My mommy told me so!
 
11:28 PM
she was lying
 
user142019
Everybody is special.
 
She also told me Santa Clause is real...
 
user142019
If you're not special, you're part of the set of non-special people. One of those people is the oldest one, and hence is special and gets removed from the set. Continue until set is empty.
 
@rightfold You're a mathematician!
 
Holland/Netherlands - few years ago, I called up cellphone co. to as about roaming charges while on business trip to 'Netherlands'. After long pause, "Sorry, we have no service agreement there... where is it?"
 
11:34 PM
@Mysticial It doesn't qualify as a Singleton if it's immutable. Then it's just a constant you access in a strange way.
 
user142019
I want to live in one of these in Rotterdam.
 
@rightfold Were those designed by Escher?
 
user142019
@MonadNewb No, by Blom.
 
It looks like an Escher-style painting
 
user142019
It's a heap of houses.
 
11:40 PM
 
user142019
Link to the actual image, not the page that displays it, you fool.
 
@DeadMG What I'm essentially doing is implementing a class where all the fields are function pointers. And functions will take a pointer to such an object and call those function pointers. I can either implement it as it is. Or I can make it an abstract class, and make subclasses with virtual methods instead of function pointers. So it's still the same, though I've pushed all the function pointers into the v-table.
 
bleh
 
user142019
But no, they don't have upside down stairs.
 
I'm sure. Just reminds me of that kind of thing.
 
11:41 PM
@Mysticial Yeah, and make the compiler generate the vtable for you and ensure it's correctness and stuff. It would be icky to generate such a table manually.
 
Furthermore, the subclasses have no fields and have no state.
 
That reminds me of those stairs.
 
@Mysticial Wait what. What devil work are you doing?
 
I'm actually redesigning some of the top-level code in my pi-program. That abstract class would be a "constant". And each of the constants are singleton instances of an actual constant. (Pi, e, etc.) Every constant must implement several functions such as:
- compute to X precision
- estimate memory needed
Right now, it's done with a struct with a bunch of function-pointer fields. And I statically initialize one instance per constant with the relevant function pointers.
 
yeah, that's definitely way uglier
if you can't use templates then IConstant would be a better choice.
 
11:53 PM
@DeadMG Which is uglier, the abstract class + virtual functions? Or the struct of function pointers?
 
definitely the struct of function pointers
 
That's what I thought too. :)
 
@Mysticial Note, function pointers vs vtable - in some cases it can be practical performance difference, because vtable would imply 2 indirections, while function pointer is just one.
 
only if you pass a big-ass array of function pointers by value.
 
@EvgenyPanasyuk That I know. In this case performance is irrelevant.
 
11:54 PM
there's no way that shit will fit in a register, it's gotta be on the stack, so I don't see how a double indirection would be avoided anyway
 
Since the engine will take the "constant" object and call estimate_memory() and print out the result. Then once the user says "start", it will call compute() and it will begin the massive computation.
So no, it's not performance critical at all.
 
@DeadMG first of all, double indirection means that func address by additional indirection.
 
that really is quite irrelevant performance then
@EvgenyPanasyuk It won't be for a vtable.
if you have a pointer to a vtable, then you can load the address of a given function pointer by simply indexing that pointer.
exactly the same as a pointer to what's basically a vtable on the stack.
a vtable is a struct of function pointers.
 
@DeadMG and how you get pointer to vtable?
by additional memory load?
 
it's a constant, numbnuts.
not to mention that one vtable pointer will fit in a register.
 
11:57 PM
@EvgenyPanasyuk On the first virtual call, yes you have two indirections. But subsequent calls to the same object can skip that first indirection since you already have the vtable.
 
@Mysticial yes
 
user142019
As long as there's beer on the vtable I'll dereference the vpointer.
 
@Mysticial btw, several years ago I measured time for virtual calls, switch'es, if chains:
 

« first day (991 days earlier)      last day (3952 days later) »