« first day (249 days earlier)      last day (4715 days later) » 

9:00 PM
the version numbers are effectively irrelevant
 
It just keeps rolling forward.
 
sbi
@TonyTheTiger Of course. And so does google, courtesy all your personal data.
 
Firefox updates itself too.
 
who cares about versioning anyways?
 
And now XP is annoying me with the bloody "I'VE UPDATED RESTART ME" crap.
 
9:00 PM
oh man
it could be much worse
 
@sbi true that :( damn do you always have to remind me of reality? lol
 
did you know what a Microsoft engineer said about a problem in Direct2D?
 
sbi
@TonyTheTiger Call me old-fashioned, but I expect something new when a major version number increments.
 
"Well, we shipped the run-time in the OS, so we can't update it."
you shipped software and you can't update it? the fuck is that?
 
@sbi lol, I've stopped relying on that
 
sbi
9:01 PM
@DeadMG Direct2D? Aren't they already at version 4D? :)
 
MS has this problem that the moment they ship something, people start to create shitty software that depends on the broken behaviour.
 
no
 
They're screwed no matter what they'll do. :P
 
And the shittier the software they make the longer people will hold on to it.
 
9:02 PM
they're ms... what else is new? :P
 
Case in point: IE6.
 
ugh :( nothing but pain on that one
 
Thankfully, IE6 was never my problem.
 
you're lucky
 
you know, I think that C++ should support having a JIT
 
9:03 PM
@Cat: Don't you do webdev?
 
just a really, really small one
 
sbi
@TonyTheTiger I try to adhere to something as old-fashioned as principles. Google has long stopped to be the Don't-Do-Evil company. I stopped believing that the moment they hired Doubleclick. Since then i try to avoid them. Sure, I have a googlemail account, and yes, I use them as a search engine, but the account is one in about two dozen I have, and I don't really see any search engine alternative to switch to. But if I could, I would.
 
why? what would be the advantages of JIT?
 
#1- convert std::function to function pointer, with an appropriate thunk managing object
 
@sbi oh I see
@DeadMG doesn't the compiler do that anyways?
 
sbi
9:05 PM
@MartinhoFernandes Only starting in two weeks, IIRC. :) Then IE6 will be his problem.
 
@DeadMG doesn't it already? What's to stop you from JIT'ing C++ code?
 
@MartinhoFernandes Never cared for IE, didn't have to. And now, I again don't have to. :P
 
#2- call function pointers only with a buffer as inputs and outputs, so you can call them with different types dynamically at run-time if you don't know them at compile-time
 
IE6 is dead outside of internal networks.
 
sbi
@jalf Doesn't VC do that already?
 
9:06 PM
@jalf: You can pass a std::function to a function expecting a C function pointer? Let me know how you did that
 
@CatPlusPlus That must be a web programmer's heaven.
 
hmmm I'm not sure I really understand the purpose of a JIT to follow your arguments @DeadMG
 
@DeadMG what's that got to do with jitting?
 
I don't know why a JIT would be better then just any ordinary compiler... what is the advantage of it anyways?
 
sbi
@CatPlusPlus IE6 had been dead 3 months after it was released, but it did manage to have its corpse lying around an stink for years.
 
9:07 PM
I mean, I know that .NET uses it... but I've only seen it being slow
 
Besides, I'll be doing backends probably.
 
well, the idea is that you jit a small function with the pointer baked in, as if it were constant
that's how .NET does it for delegates -> function pointers
that just forwards to the real function with a "this" pointer extra argumnet
 
sbi
@CatPlusPlus Arses?
 
@DeadMG but that's not a property of the jit compiler. That's just how they define the language semantics
 
@sbi lame
 
9:08 PM
that's how those semantics are implemented
 
made me laugh though
 
that's completely orthogonal. You can define that kind of delegates without jitting, or you can jit without modifying C++'s semantics
 
how could you implement delegates like that without jitting?
 
You need metadata to jit.
 
sbi
9:08 PM
@TonyTheTiger I know. You laugh about all my lame jokes. :b
 
Damn, what kind of a verb is "jit"?
 
Jitty.
 
@DeadMG simple. You write in the language spec that this is how delegates should behave
 
"I'll be just-in-timing stuff for a while."
 
right
 
9:09 PM
also, .net doesn't have function pointers
 
sbi
@MartinhoFernandes It rhymes with "shit". What more do you need to know?
 
it does for interop
 
"Could you just-in-time that for me?"
 
a .NET managed delegate of a member function will convert to a C function pointer with the same signature, and magically remember the object that it's being called on
 
"You've earned the "Notable Question" badge for Rails: Reconstructing ActiveRecord Objects from a JSON array.. " lol I think I earned the most rep with the dumbest question
 
sbi
9:10 PM
Anyway, it's time for me to hit the sack. See you guys tomorrow!
 
@sbi I guess that makes me the lame one then :(
 
I don't see why it has to be jitted. Why couldn't you generate that function stub at compile-time?
 
where would you get the this pointer from?
 
@sbi Good night.
 
@DeadMG I don't see the problem at all. Pass it as a parameter? Like you'd do with a C++ functor
 
9:12 PM
only if the C function pointer in question allows for that
what if it doesn't?
 
again, I don't see the problem. Statically define a unique function stub for each such callback.
 
that's not re-entrant
 
Or place the this pointer at some predefined offset from the function
or encode it as a table lookup
.NET code isn't always jitted either. YOu can precompile it with ngen
 
sbi
@DeadMG To spare you a lengthy, pointless, and embarrassing discussion, I'll throw you one more bone before I go to bed: BCB used to have real a real closure syntax without JIT.
Good night.
 
real closure syntax != stateful closures can convert to function pointers
 
9:15 PM
@DeadMG of course they can be converted to function pointers, if you have control over the function, and the environment around it
 
well, the reason that I suggested for it to be in the language/Standard library is because I think that it's a general enough problem not to be re-coded for each platform by everybody who might want that
being able to have stateful closures generically convert to function pointers would be a large step forward for interpreted language bindings
especially those that wish to remain only dependent on Standard behaviour
in fact, if stateful closures could convert to function pointers generically at run-time, and you could call function pointers at run-time with dynamic types, even only POD dynamic types, then interpreted languages could use C-style interfaces with no explicit binding from C++ at all with the help of a library-loading function like GetProcAddress
which I, at least, think would be a big thing
static reflection would also be nice
 
Anyone care for some Java? :)
2
Q: Simplify writing custom iterators in Java

FredOverflowWriting iterators for custom collections in Java is quite complicated, because instead of writing straight-forward code that provides one element after the other, you essentially have to write a state machine: public class CustomCollection<T> implements Iterable<T> { private T[] ...

 
ugh Java
 
9:32 PM
@FredOverflow Writing iterators in Java is a mess.
I tried it once, and I hope I'll never do it again.
C# rules on that aspect.
 
Writing anything in Java is a mess. :P
 
@MartinhoFernandes Have you read my answer to the question yet? ;)
 
I think I'll +1 just for the Option type instead of timebomb.
I mean, null.
 
I had to write it because ArrayBlockingQueue does not accept null as input :)
But how a modern language can lack something as basic as an Option type is beyond me.
Was boost::optional incorporated into C++0x?
 
You know, from the Java community, you'll probably get a "you don't need Option, you have null".
And then there's the fact you can't have Option<int>.
 
9:40 PM
@FredOverflow No, AFAIK.
 
Ah, so C++ and Java have two things in common: curly braces and the lack of an Option type :)
 
@FredOverflow Confirmed it, no :(
 
It's in Boost, good enough.
 
Now, about the answer. It's a clever use of threads, but I can see a couple issues.
 
@MartinhoFernandes I'm sure you can, it's just a funny hack I came up with today ;)
 
9:42 PM
C#'s yield can deal with exceptions for starters.
 
ok
ok, ok, ok
number one reason not to slack around all day stuffing myself
stuffing self yields sickness, as I should have learned by now
 
> stuffing self yields sickness, as I should have learned by now
Was that intended? :)
 
no?
 
Because we were just discussing C#'s yield :)
 
sure, but I routinely don't read what you say :P
 
9:45 PM
You can use C#'s iterators to get free lazily instantiated infinite sequences.
 
can you have two [] operators for the same class..?
 
just kidding
@Default: Only if they take different argument types
 
Your solution will keep a thread running forever.
 
@Default Why do you ask? Normally, you have a const and a non-const overload.
 
9:46 PM
But I like the idea overall. It's ingenious.
 
What can't directly do is have a "multidimensional operator[]".
 
oh, oh
 
You could want to access by order (int index), and by name (string index) for example.
 
I have a Directoryimplementation and I was wondering how it would be best to return the files and directories.
in school I learned not to return the actual vector (because that can change) so I should have a `count()` and a `getElement(int index)`
but I think te `operator []` looks better
 
that was so on the list of things that DeadMG++ could do
implicit operator chaining
 
9:48 PM
It'd be cool if comma operator created a tuple.
 
Of course you can always keep a separate map around.
 
damnit, my formatting just won't work in here >:/
 
Markdown shuts down for multiline messages.
 
@CatPlusPlus: You could always overload it :P
 
@CatPlusPlus ah. so that's why
 
9:48 PM
@CatPlusPlus Boost does that.
Not for tuples, but for collections.
 
@MartinhoFernandes Really? Which one, the producer or the consumer?
 
Oh, I know Assign, I use it from time to time.
But I was thinking about foo[1, 2] where 1, 2 would be packed into tuple<int>.
 
@MartinhoFernandes Ah, exceptions. Yeah, I could just catch the exception and put it in the queue, and then re-throw it later. Will work on that...
 
AFAIK, you can't overload for basic types, no?
 
9:50 PM
@CatPlusPlus One operand must have a user-defined type.
 
@FredOverflow Nevermind that. A little oversight on my part.
 
Phew :)
 
Yeah.
 
I guess however that directory[0] wouldn't make much sense anyways.. oh well
 
Wait, when the consumer stops consuming, the producer of an infinite sequence will fill the buffer and then block, right?
Is there a way for it to know if you stop mid-iteration?
Even for finite sequences.
Like a simple search for(Foo item : items) { if(item.invalid()) break; item.doStuff(); }
 
9:58 PM
Interesting, I hadn't considered that!
 
But I don't think you can work around that one :(
 
Damn you, Java!
This is why feedback is important, I wouldn't have envisioned that problem on my own.
By the way, writing iterators in C++ isn't any less of a pain, is it?
 
I never tried, but I think it's similar.
The design is different, but the pain seems the same.
Is there something in Boost that gives me lazy iteration?
std::transform requires me to compute everything into a new collection.
 
There's Boost.Iterator, but I never really looked into it.
 
(I think I'm just way too spoiled by LINQ.)
 
10:04 PM
@MartinhoFernandes Can you post that as a comment?
 
@MartinhoFernandes Or do you want to wait and see if someone else finds the same problem? :) Could be interesting.
 
Oh, sounds better.
:)
 
> The function output iterator adaptor makes it easier to create custom output iterators. The adaptor takes a unary function and creates a model of Output Iterator. Each item assigned to the output iterator is passed as an argument to the unary function.
Oh, there's transform_iterator.
> The transform iterator adapts an iterator by modifying the operator* to apply a function object to the result of dereferencing the iterator and returning the result.
 
Suppose this std::enable_if<false,void> foo() { } – Why does a call foo<int>() compile?
 
10:06 PM
@MartinhoFernandes That's what you looking for?
 
@KarlvonMoor Because you are defining a function that returns an object of type std::enable_if<false,void>. What you really want is:
typename std::enable_if<false,void>::type foo() { }
 
Oh
Thanks a lot!
 
you're welcome
 
10:10 PM
Hmm, nasty.
Returning metafunctions.
Oh, another thing I realized when I tried to implement iterators in Java was that their model with hasNext()/next() is a lot more hassle then C#'s MoveNext()/Current.
Even without yield, C#'s iterators are easier.
The difference in semantics is that Java's hasNext() does not advance the iterator.
 
I prefer C++'s model (current, compare, move).
 
Java merges move and current, which complicates writing them.
 
right
 
With "current" separate, the implementation can simply return a value previously stored in "move".
I'll post that comment now.
 
10:22 PM
35 mins ago, by FredOverflow
What can't directly do is have a "multidimensional operator[]".
Why haven't they gotten around to this yet?
 
@Fred, do you know you can keep more than one class in the same .java file?
 
@Xaade Because you can simulate them with proxy objects.
 
Just don't make them public.
 
@MartinhoFernandes Yes, but why would I want to?
 
@FredOverflow ZOMG.... how.... how????
 
10:23 PM
Or use operator() instead.
 
To make posting on SO easier :)
 
@Xaade Let operator[] return an object that overloads operator[] for the second dimension?
 
@CatPlusPlus Yeah, but that just looks like you're the kid that can't afford a better compiler.
@FredOverflow Like getsomething[][]
 
It's certainly less coding effort than making a proxy. :P
 
But what if the first [] returns null. If you do that, then get[-1][0] would be a memory error.
 
10:26 PM
foo[i][k] is just syntactic sugar for foo.operator[](i).operator[](k), right? So foo.operator[](i) must return an object that, when operator[](k) is called on it, returns the appropriate object.
 
final question for today.. should I use boost asio for measuring time?
if I want to do:
 
It usually returns the proxy as value, not a pointer.
 
You must return the proxy object by value, anyway. Otherwise you can't use the [] syntax on it. Well, unless it is a raw pointer, but those are kind of proxy objects for arrays :)
 
long start = StartTimer(); doCalculations(); long end = EndTimer();
 
oh..... so you mean, the proxy is an object that always exists, that just forwards the first index to a method that can get the "grandchild".
 
10:28 PM
It does not have to "always exist", it can be created when it is needed, but it knows its parent (simply by storing a pointer to it or something).
 
But what if A is a list of Bs that each is a list of Cs.
I want A[] to return a B, and A[][] to return a C.
If A[] returns a Bproxy, then A[] can't return B.
 
or maybe use ptime..
 
If you have nested lists to begin with, then you don't have to write proxy objects at all. Just let operator[] on A return the B, which in turn already provides its own operator[], right?
 
If B has C operator[](...), I don't see a need for a proxy.
 
Can sm1 pls show me how to get the running time Big-oh of this pastebin.com/Fx7w2LXE ? especially for the "if" inside inner while
 
10:29 PM
@MartinhoFernandes right
 
Um..... ok.... but what if A[15] is out of bounds.
It returns a B that notifies you its not a valid B.
 
@Xaade Then operator[] in A should throw an exception?
 
Pregnant Girlfriend (aka UB).
 
You either check the bounds and throw, or don't check the bounds and crash.
 
AH.... exceptions.... yeah.... I didn't think about that, because I don't use them.
I don't like wrapping everything in try.
 
10:30 PM
@coder9 What language is this?
 
try{ code line 1 } catch{ } try { code line 2} catch { }.... seems a little overdone.
 
@Xaade You shouldn't handle exceptions for index out of bounds.
 
@FredOverflow going to implement in C++ . still its in pseudo
 
@Xaade Exception handling is not mainly about "wrapping everything in try"...
 
You should fix the bug instead.
 
10:31 PM
@MartinhoFernandes right, because that is a programming error
 
Hmmm
I see
But what if you give the user access to determine the item they want to select?
 
Eric Lippert calls them "boneheaded exceptions".
 
Do you check the bounds before you call A[][]
 
Your program should crash horribly, and as soon as possible, when you discover a programming error.
 
> Boneheaded exceptions are your own darn fault, you could have prevented them and therefore they are bugs in your code.
 
10:32 PM
@Xaade You write the code in such a way that you don't access out of bounds.
 
Like checking bounds first before using my operator?
 
for (int i = 0; i != foo.size(); ++i) { foo[i].whatever(); }   // no need to check
 
Or just catching it and telling the user they tried to access something out of bounds.
 
@Xaade Which user? Does the index come from a GUI text input field or something?
 
Yeah
 
10:33 PM
You test it against foo.size() before indexing.
 
right
 
@FredOverflow any idea?>
 
So, if (X > foo.size() || Y > foo[X].size()) { // dosomething to warn user}
 
Oh, see, that would work great if the indexing was to an array.
But there's not necessarily an object at every index.
 
10:36 PM
Then you need a means to determine that.
Like std::map::find().
 
@coder9 Sorry, I'm just too old to read uncommented source code where all variables are untyped and have names consisting of a single letter.
 
if ( foo.exists(X) && foo[X].exists(Y))
 
@Xaade Actually, >= size, because valid indices range from 0 to size-1.
 
Ok, thanks all....!!!!
 
Classic off-by-one error.
 
10:38 PM
Yeah, I typically don't copy code from my chat messages.
 
@coder9, if that is Prim's algorithm to find the minimum spanning tree of a graph represented as an adjacency list, and is correct, then it's probably O(E log V).
 
@MartinhoFernandes how to get running time for the "if" statement which is inside two while loops?
 
Huh, I don't understand. The if statement is constant time.
Is this a valid technique to get the index of an element in a vector: auto index = max_element(v.begin(), v.end()) - v.begin()?
 
Seems reasonable.
But you may want to use std::vector<T>::size_type instead of int.
Especially for large vectors on 64 bit systems ;-)
 
What int? I used auto.
 
10:49 PM
LOL, must be my imagination, sorry.
Then you'll probably get std::vector<T>::difference_type.
 
difference_type must be at least as big as size_type, no?
 
yes
if you had a vector of numeric_limits<size_t>::max() size, then difference_type would have to be as big as size_type in order to tell the difference between element 1 and element numeric_limits<size_t>::max()
 
11:13 PM
what are non-trivial examples of complexity classes?
 
I'm still going in circles around this ideone.com/zeO26. WTF am I misunderstanding?
 
11:32 PM
@coder9 What exactly do you mean? Here is my standard list of examples:
O(1): lookup in a hash table
O(log n): lookup in a binary tree
O(n): lookup in an array
O(n log n): mergesort
O(n²): insertion sort
@MartinhoFernandes I think I have found a work around :)
 
Oh, nice, what is it?
 
weak references :)
The producer can notice that the consumer doesn't access the queue anymore if I use a weak reference for the queue inside the producer.
WeakReference<BlockingQueue<Option<T>>>
Is that ugly or beautiful? :)
 
Seems feasible.
But you'll need a way leave the blocking call to enqueue once in a while and check back.
I'm sure there's something, but I can't remember it.
 
The only waiting I do is in the consumer.
 
I meant enqueue, sorry.
 
11:41 PM
There's a timeout overload for BlockingQueue.put.
 
That.
That lets the thread terminate and garbage collection work again.
The only loose thread is the damn non-determinism of garbage collection.
The producer can end up producing more than is needed.
If there are side-effects in the mix (which shouldn't, but I'm just pointing it out), or if it's an expensive operation, the results won't be the expected.
 
@MartinhoFernandes If that's a concern, I could limit the queue to max capacity 1.
 
That helps.
@Override
protected void provideElements()
{
    for (int i = 0; i < size; ++i)
    {
        provideElement(data[i]);
    }
}
This code won't run in the same thread as the client.
Now I wonder, could that cause concurrency issues?
 
where is your lock around the container? size can change.
not even talking about what provideElement might do.
 
@TomalakGeretkal provideElement enqueues. It's a final method on ConcurrentIterable.
 
11:48 PM
@MartinhoFernandes and that means precisely squat to me
(and, by extension, anyone reading the function definition)
 
Oh, sorry, we're talking about this: stackoverflow.com/questions/6446505/…
 
you're going to direct anyone maintaining your code to an SO question?
hmm, C#. don't suppose you read the chat room name lately.
 
No, that's the code we're discussing.
And it's Java :(
 
It's Java.
 
It's @Fred's fault!
 
11:50 PM
then why is it tagged ?
(also, the point stands)
 
Fred is trying to replicate some C# functionality.
 
.. then why is it tagged ?
hey, I can do this all day.
btw do you like my use of tags? I like it. tbh if I'm being difficult it's only so that I can use as much as possible.
I just have a thing for buttons that you can make out of Markdown
 
11:52 PM
 
@TomalakGeretkal ArrayBlockingQueue is a concurrent collection, no need for manual sync in my case.
 
@Fred did you consider the concurrency issues I mentioned above?
Granted you need evil code on the implementation of provideElements, but still...
 

« first day (249 days earlier)      last day (4715 days later) »