« first day (443 days earlier)      last day (4488 days later) » 

user142019
10:00 AM
"Copies the n-th stack item to the top." then it is not a stack.
 
why not? he inserted at the top
 
user142019
Stacks should only provide access to the top item.
 
It's a stack with super powers!
 
no
 
user142019
It's a random-access-stack.
 
10:01 AM
stacks only provide the ability to remove the top item
reading the other items isn't against being a stack at all
 
All stack languages have complex stack manipulations.
 
They wouldn't be very usable otherwise.
 
exactly
 
user142019
FALSE isn't usable anyway.
 
lol
> Please refer the below piece of code.
Is this correct English?
 
10:02 AM
no
 
I'm seeing this a lot around SO lately.
Is it some Indian idiom thing?
 
user142019
I'm not.
 
user142019
lol
 
I see mainly users with Indian-sounding names using it.
 
user142019
0
Q: How to delete Singleton pointer?

AtulI was implementing a singleton pattern.Here,I am creating a new instance of Singleton* in GetInstance, when I try and delete it in the destructor, it does in infinite loop. How to avoid memory leak in this case ? Please refer the below piece of code: #define NULL 0 class Singleton { ...

 
user142019
10:04 AM
Why use a pointer?
 
The question is "why use singleton".
 
Dunno. People not only like to write singletons, but on top of that they also like to write them with bad code.
 
there are non-bad Singletons?
 
fixed'ski
 
10:06 AM
Maybe non-state singletons. Like nullptr.
 
Can't you do std::nullptr_t()?
 
@RMartinhoFernandes Maybe they like consistency.
 
user142019
Singletons have uses like a logger but allocating it dynamically is bullshit.
 
nullptr isn't a singleton. I can create as many new null pointers as I like
 
@WTP Well, I guess that I never wanted to log remotely or something as well as locally...
 
10:07 AM
Fine, Python's None.
 
user142019
nullptr is a constant of type std::nullptr_t.
 
Factor has singletons like that. "A singleton is a class with only one instance and with no state."
 
which leads to the question of why (barring language limitations) you need an instance at all
 
user142019
Objective-C has the NSNull singleton -_-
 
Well, the class itself is that instance.
 
user142019
10:11 AM
Which is used "to represent nil in cases an object is required."
 
That sounds crazy.
Lemme see if I got this right. Objective-C is yet another language with schizophrenic null values?
 
Yay, consistency.
 
@CatPlusPlus only in a prototype-based language, no? Afaik, python distinguishes between classes and instances?
 
@jalf I was talking about Factor here.
Python has None and NoneType, yeah.
 
user142019
@R. All objects in Objective-C are pointers of type id and nil is (id)0.
 
10:13 AM
@CatPlusPlus oh right
 
Objective-C also has NULL.
 
@WTP So, there is nil and NSNull, which are not the same thing?
 
Consistency!
 
Oh, right, and the C inherited NULL.
 
user142019
The worst thing is that sending a message to nil doesn't crash, sending it to NSNull does.
 
10:13 AM
Right, schizo.
Add a few more and it may beat old Visual Basic.
 
Why have one null when you can have 3.
They should add NSBetterNull in some future version.
 
user142019
One that isn't a singleton.
 
oh, by the way
 
Classic VB had Null, Nothing, Missing, Empty.
 
user142019
And responds to all messages sent to it.
 
10:15 AM
All distinct and incompatible.
 
NSFileNotFoundNull
 
what do you guys think of cutting the index operator [] and just using () instead in all cases?
 
Reminds me of VB.
 
user142019
C++ has 0, ~(~0), NULL and nullptr.
 
that's not true at all
 
10:15 AM
Those are all the same.
 
Xeo
No, we have 0 and nullptr
 
~(~0) will be 0, NULL is #defined to be 0
and nullptr and 0 are different things for the type system, but they produce the same representation when as a pointer
 
user142019
Nice.
 
Xeo
Anyways, off to sleep
 
so basically, there's just 0 and type-safe 0
 
Xeo
10:17 AM
g'night
 
night
 
> But beware about using singletons. They are not evil, as some here think the are (I find that position irrational), but they are very easy to misuse and hard to use correctly. As a rule of thumb, don't use singletons for your "interface classes" (the ones that are used by other parts of the program); try to use singletons only as implementation details and only when it feels appropriate.
 
user142019
It's 11:17 in the morning.
 
And it's only one null value. You just have different ways of typing it.
 
Xeo
@WTP Yes, and?
 
10:18 AM
> Add a static member Singleton::DestroyInstance() that delete the instance and call it from the main.
Lol.
 
@CatPlusPlus Gotta love "(...) only when it feels appropriate."
 
user142019
You said g'night.
 
linky?
@WTP He's in a different time zone.
this is the Internets, don't assume everyone is at the same time as you
 
Xeo
@WTP night -> when I go to sleep. Next day -> after I slept
 
It's the delete singleton pointer thing above.
 
Xeo
10:19 AM
I thought that was the rule for everyone?
 
@DeadMG Actually, they are in the same.
 
and that, as well
 
user142019
K g'night.
 
@RMartinhoFernandes I thought Xeo was in Merika?
or maybe that's Xaade
 
10:19 AM
right
 
Xeo
I'm not a merkin :|
 
Xeo is in Germany.
 
Xeo
right
 
night
 
Xeo
fight
 
10:20 AM
Might.
 
height
 
Xeo
fright
 
Xeo
more at 11 tonight
 
In other news, DOOM.
 
10:22 AM
MORBO CRUSH
 
Boost.Serialization has singletons?
 
dunno, I've never used it
 
Maybe somewhere in the bowels.
I haven't seen anything user-visible.
 
Ok, how can I grep for that?
 
grep for something like Instance I guess
 
10:27 AM
Uh, does , make sense for cons?
 
If I wrote a singleton I'd just name the function get().
It's obvious it gives an instance.
 
not obvious it gives the same one every time, though
 
@RMartinhoFernandes I've been abusing get as a member name. I'm trying to move away from that.
 
And getInstance does?
 
I think it makes it more clear
get() could get anything
 
10:28 AM
I don't see how (other than indoctrination from existing singletons)
 
I'd name it fuck(), just for kicks.
 
It could get you a different instance each time.
 
I'd never write a Singleton, so I haven't been indoctrinated into any Singleton practices :D
 
get usually returns something stored, not creating new stuff.
 
@RMartinhoFernandes At least that'd be limited to instances instead of, say, an int or std::string
 
10:29 AM
Those are called create or make.
 
@DeadMG That's what the return type decides, not the name.
it()
 
only trivially available if you don't, say, take it by template
 
@CatPlusPlus how about operator()?
 
@jalf Not static.
 
singleton::moo()
 
10:31 AM
lol
 
by the way
I've been thinking about cutting the increment operators from WideC
 
@RMartinhoFernandes oh right, fair point :)
 
I don't think that they genuinely deserve their own operators
 
@sbi Good point. Comma isn't very intuitive
 
10:33 AM
There it is: <boost/serialization/singleton.hpp>.
 
@DeadMG As much as I ignore increment/decrement for arithmetic types most of the time, I still cringe when I read the names that other languages use like it.next() or whatever.
 
true
 
for an imperative language, I think they're worth having
 
but if you cut them, and do a tiny bit more swiddling, then you can remove semicolons and all sorts of other separators
which, IMO, is a good goal, because they're annoying
 
@DeadMG sure about that? ;)
 
10:34 AM
yes
 
If you cut them, you can give strings their very own concatenation operator!
 
sounds like it's time for you to learn about hg branches then. Create a branch, see how it works out
:)
 
I mean, there are a couple more examples of operators whose form would have to be changed to remove them
 
@RMartinhoFernandes Doesn't look like it's used anywhere, though.
 
like address-of
 
10:35 AM
@jalf 100 rep says he'll be here next week complaining about a branch that ate his source code.
 
Next week? More like next day.
 
@CatPlusPlus void_cast.hpp
 
sbi
@RMartinhoFernandes There's that "100 rep" guy again.
 
oof, was such a pain getting the debugger to wake up on this assertion failure that I don't dare restart the process and have to do it again. Would be nice to be able to break into the debugger a bit earlier though
 
the real question is
 
10:38 AM
"Soup?"
 
how on earth does Lua know to tell the difference between function call expression expr(function_call) and expression expr and primary expression (expression)
 
sbi
@DeadMG Maybe the + gives it a clue? Just asking...
 
nah that was typo on my part
 
Magic.
 
I mean, I guess that logically, () isn't a valid primary expression, and nor would be (expression, expression) as there is no comma operator
but in the single expression case, I don't see how it isn't totally ambiguous
 
10:40 AM
0
Q: Open source virtual machine management tool in python

capersky 48I am planning to write simple virtual machine management tool in python [Turbogears,Sql alchemy]. The tool will have the capability to create,delete,upgrade a virtual machine on Xen hyper visor. Can any one advise on some docs or some links for the start ? What are the necessary libraries requi...

Lol these people.
 
@DeadMG because it doesn't have semicolons to separate the two, you mean?
 
yes
 
just trying to follow your logic here. Been a million years since I even looked at Lua
 
yes, in C++, then you'd have f; (expression); or f(expression);
but in Lua there are no semicolons
 
it doesn't have significant line breaks or anything either? Is expr expr valid?
 
10:45 AM
yep
 
ick
 
Context-sensitivity?
@jalf That's the INTERCAL compiler.
 
@DeadMG There are. Do you mean they are not always required?
 
if I had to guess, they just resolve the ambiguity by giving precedence to function call syntax.
 
they're never actually required, as far as I know
 
10:47 AM
anyway, hasn't anyone written a lua grammar you can look at?
 
sbi
Russian brides, college degrees, executors of deceased millionaires & wealth of pharmaceuticals. My inbox is filled with (im)possibilities.
:)
 
they have
that's what I'm looking at
 
One day a real prince will need help to take a large quantity of money out of his civil war-torn country and he'll be hopeless.
 
Doesn't it use newline as a statement separator?
 
ooooh, I think it's because they don't allow expressions to be statements, in general
you can't have a + a as a statement
 
10:48 AM
ah
 
only function calls can be statements in as of themselves
 
that'd be sane too :)
 
@CatPlusPlus Nope.
well, it's certainly an interesting approach
 
it is kind of a hack that so many imperative languages allow expressions to be statements
 
sbi
@RMartinhoFernandes Um, is that supposed to be short fiction? Because I can't make heads nor tails of it.
 
10:50 AM
well
I would be perfectly happy to do the same
 
a kind of "oh shit, we painted ourselves into a corner here, what's the least intrusive way to get things working again?"
 
but I'm concerned about how it would interfere with e.g. expression templates
 
yeah
 
I'd be enforcing the primitive language semantics in the grammar, which is not necessarily a place I'd really like to go
 
agreed :)
 
10:52 AM
although here's the thing, I guess that you could just have like, dummy return values if you really, really wanted to work around it
 
but as long as expressions are valid statements in themselves, stuff like avoiding semicolons gets a lot trickier
 
yes
 
@DeadMG how do you mean? Like instead of a void return type, return nil or something?
 
well, I was thinking of nullptr, but close enough
I actually flat out never noticed that something like a + a would not be a legal Lua statement
 
I know some languages do that, and philosophically I think that's nicer than the kind of special-case "some functions don't return anything at all". Preferable to say that some functions just return a very uninteresting nil object or something like that
 
10:54 AM
I have no problem with it conceptually, but being forced to take that return value wouldn't be fun
 
@sbi It's an XKCD reference.
 
but I guess, even in the case of things like Spirit, the expressions do yield useful values
 
@DeadMG how do you mean?
 
well, if you want to distinguish grammatically between what has side effects and what doesn't, then you need to allow assignment statements too
although I guess you could always call some empty function that takes anything and does nothing
 
10:59 AM
you lost me there
 
although Bison insists that actually, having statements only be assignment expressions got me exactly diddly-squat
 
IIRC it's idiomatic in Lua to sometimes write things like _ = foo and bar instead of conditionals. So assignment statements indeed.
 
have to admit, Lua's or statement is fucking awesome
but only for the dynamically typed :P
 
11:18 AM
Python explicitly makes assignment a statement.
 
yeah
unfortunately, according to Bison, that doesn't improve my situation at all compared to any expression
 
11:32 AM
ok
the problem is that (expression) is too low
it shouldn't be on the LHS of an assignment
 
11:53 AM
Ah, this singleton guy is great
now he's arguing that singletons can be justified because you can define them to allow explicit copying of the object
 
uh
that doesn't make it a Singleton anymore?
linky?
 
@DeadMG exactly :)
4
A: How to delete Singleton pointer?

Paul MantaHere's a more correct implementation of singletons: class Singleton { public: static Singleton& Instance() { static Singleton inst; return inst; } protected: Singleton(); // Prevent construction Singleton(const Singleton&); // Prevent construction...

 
I'm starting to notice that a lot a singleton defenders fall back to defending not-so-singletons very fast.
 
Could someone take a look at this real quick? pastebin.com/8ScMsFa2
 
@pubby what about it?
 
12:03 PM
@sehe does the first syntax make sense?
 
how can we tell? is it supposed to be an existing functional language? Is it your C++ macro proposition?
 
It is mockup functional
 
the use of template aliases seems fascinating there. I knew they would be good for more than I anticipated but I'd have to look real close how you you used them
 
I'm not sure if the aliases will work
I used them as flip's argument f could take more than 2 parameters
 
I can't check. I'm on gcc 4.5.3 at work :)
 
12:07 PM
Oh, doesn't compile anyways. Missing some of the functions
addition, subtraction, etc
 
hmmm sorry I don't feel qualified to 'judge' a non-complete/non-formal functional programming language's syntax by a single example. Especially since I'm guessing about the design goals (I'm assuming easy and deterministic translation to C++ TMP functors?
)
It looks cool, though
 
Thanks
 
> In this case, singletons are used more as access controllers rather than as a way to design your class. So naming them "singletons" is rather unfortunate, but not because the name is inappropriate.
Hehe, "Seems what I like is not singletons after all".
 
I can't process what he wrote there.
> You can design T as it should be designed, and if you need a global instance you can wrap it in an access controller to ensure that no matter how the original class works, you can't misuse your global instance.
 
I doubt I'll ever know what kind of misuse this is protecting against.
@Pubby Sorry but that sucks. It should be fun flip -> curry . (. swap) . uncurry. :P
 
12:18 PM
@RMartinhoFernandes ???
 
Don't mind me. I like to write stuff pointfree. That way I can spend hours trying to understand it later.
2
 
: flip ( quot -- quot' ) '[ swap @ ] ;
 
@RMartinhoFernandes I thought (. swap) was sugar for flip (.) swap
 
Fried quotations. Yum.
 
@Pubby Yes, they're equivalent.
 
12:31 PM
@RMartinhoFernandes So it's infinite type??
 
No. The type of flip does not depend on itself.
 
I can't compile this: let flip = (curry . (flip (.) swap) . uncurry)
(without using prelude flip)
 
Because it's infinite recursion.
Dunno about compilation.
 
Yeah, but is pointfree flip possible?
 
Yes. Just like I wrote it above.
 
12:35 PM
Robot's version is point-free.
 
Sections are part of the language. They do not depend on flip.
 
I still like my version better.
 
My syntax doesn't have right sections :S
 
Hmm, let's see if $ pointfree can help :)
$  pointfree "(\f x y -> f y x)"
flip
Dammit.
It's too smart.
 
a bit of help on circular queues please?
 
12:46 PM
@anonymouslyanonymous: very good you are asking this non-question anonymously :)
 
let me get it straight...you add elements to the end remove elements by moving the start position of the queue higher and you print them from front to rear
 
that's implementation dependent
 
you add elements to one end, and remove ('pop') from the other end. There, circular queue.
You can implement it in many many ways. e.g .Lockfree implementations will be very different from non-lockfree implementations
 
printing always happens from start to end?
 
12:48 PM
You can have implementations with strictly monotonically increasing indices which are even more optimized for concurrency.
 
Printing is a boring thing to do with a queue.
 
@anonymouslyanonymous depending on your definitions, yes. The usual jargon is FIFO (first-in-first-out)
 
@sehe There's too many instances of "anonymous" in that message.
 
@anonymouslyanonymous no, quite often, printing doesn't happen at all
 
12:49 PM
@CatPlusPlus A queue doesn't even print :)
 
printers suck
 
Especially if it's a printing queue.
 
@sehe Ever heard of printer queues?
 
hehehe
 
12:51 PM
what are templates used for?
 
Writing generic code.
 
for anything
 
Stress-testing CPUs.
 
calculating prime numbers, and so on
 
We are the helpful bunch :)
 

« first day (443 days earlier)      last day (4488 days later) »