« first day (309 days earlier)      last day (4641 days later) » 
01:00 - 15:0015:00 - 00:00

1:58 AM
0
Q: Where to find code for interpreting c escape sequences?

fuckvimmeanpeopleThey'll passed as args to program (like \t) and I'd like to be able to interpret them as such.

LOL
 
 
5 hours later…
6:28 AM
/usr/bin/mywidget -\\t -\\n — \t activates verbose mode and \n suppresses prompts
wow, it's been slow today. Hi everybody!
 
 
2 hours later…
user53670
8:28 AM
Is there somebody know python?
 
9:03 AM
morning
 
9:15 AM
gmorgning
 
Am I doing something wrong? I think the code doesn't evaluate * properly :(
I think b*tch should not match bitch but b.*tch should.
 
are you sure matchstar should call matchhere? things get recursive
 
@Nils: It would be easier if the testcase actually printed something...
And did not have the warnings.
 
it prints stuff
I don't get a single warning with clang.
ah selected c++ instead of c
 
9:26 AM
yeah
@Potatoswatter the code is from the book "Beautiful code"
 
Is this exactly what came from the book? I assume you've modified it with your solution.
 
Not so beautiful :)
 
I would avoid lookahead such as if (regexp[1] == '*')… it's easier to advance everything 1 char at a time and keep state in variables.
 
@Potatoswatter yes the functions are copy paste, only the main and test stuff not.
but it is not matching correct?!
if (regexp[1] == '*')
    return matchstar(regexp[0], regexp+2, text);
this however looks right to me
 
One problem with matchstar is that it isn't greedy enough. Proper regex * matches a maximal substring; this one quits as soon as the remainder or the regex after the * is satsified.
As a result, its computational complexity is too high. This program slows exponentially with the number of stars in the expression, I think.
 
9:33 AM
yes that is also what the text says, the book is copyrighted but flazx :D
but is it working correct? I guess not
int matchstar(int c, char *regexp, char *text)
it should be char c, right?
 
Hmm, but then again it needs to be done this way if you want .* to work at all… :P
 
"it is interesting to see that the Java implementation runs roughly six or seven times slower than the C versions."
 
I'm guessing it's also a bit less buggy.
 
brb
 
9:55 AM
ah duh. It works because the pattern is zero or more b's followed by a "ch". So the substring "ch" alone matches, and that is contained in "bitch"
 
10:07 AM
d'ouh!
I hate if I run into trouble with such basic stuff, thanks @Potatoswatter!!
 
np, i had to step through the code to figure it out :vP
That code is anything but beautiful, though…
 
so bi*ch does not match bitch
 
right
or ^b*ch$
Best Star Trek episode ever: "The Royale"
 
Now let's turn it into iterative functions!
I have great trouble converting recursive stuff into iterative.
 
I posted an answer with a lot of code.
Perhaps people could look at it and spot errors (there are always errors).
It's at
0
A: Dancing Dolls Problem : on GCC linux

Alf P. SteinbachI think, most important is to be aware that your question is about an exercise that (apparently) at one time was designed to be easy and interesting. However, that was long ago, and meanwhile both hardware and software has progressed. It is no longer easy to access physical memory. And, at least...

In particular, I don't know if it works in Linux.
As I recall the OP stated that he's working in Linux.
 
10:21 AM
humm shall I install dosbox now
or do some cud a stuff?
:)
wow @AlfPSteinbach what an answer!
down with you!!!
 
my degree sucks balls
 
?
 
10:59 AM
@DeadMG are u getting an arts degree?
 
no
compsci
 
what sucks about it?
actually I'm quite happy
 
it consists of "learn theory from board, regurgitate theory from board"
I got questions that were things like, "What is the formula for a two-dimensional rotation matrix"?
 
That's a problem with the curriculum, not the degree.
Also, it sounds like you don't have the degree yet…
 
I don't
 
11:01 AM
ok I suggest you visit this school for a day ehs-dresden.de and then tell me weather ur degree sucks or not :)
 
I can't read that site, even if any school gives meaningful teaching material on their website, which they don't
 
realx dude I guess ur school is not that bad
 
Well, I only ever took 2 CS courses: intro compilers and intermediate compilers. They were OK. All my other engineering courses were EE.
Self-education in CS FTW.
 
what definition of "bad" is there except "never write any code always regurgitate easily-Googled theory"?
 
degree in christian education matches the definition of bad quite well
@DeadMG still curious where du u study
?
 
11:08 AM
think I'll keep that private
 
@DeadMG The fact that you can look up the theory is very good.
 
no, it's very bad
 
A truly bad curriculum would require you to regurgitate errors, or use nonstandard terminology.
 
asking me to memorize it is a hideous waste of my time
 
No, memorization is good. If you could get through without committing it to memory, that would be bad.
The point of education is to put things in your memory…
 
11:09 AM
no, that's an outdated, archaic model
the point of education is to allow me to create things
I don't need to memorize a rotation matrix formula to create a rotation matrix
the only things worth committing to memory are how to use rotation matrices- pitfalls like Euler angles
 
Maybe not, but it doesn't hurt, at least in that particular example.
 
yes
it definitely does hurt
I could Google the formula faster than I could write it on the examination paper
and it's insanely demotivating
and thoroughly pointless, a gigantic waste of effort by all parties concerned
the university has to waste lecturer time marking that question, you know
and the students who don't memorize stuff by rote will get marked down, even though they're perfectly capable of creating stuff using a rotation matrix
 
explain cramer's rule to a 10 year old
i think that's a challenge. especially when only half remembers some vague things about it. :-)
 
why would you ever want to?
 
the person might have an avid interest in things mathematical, and might be asking
 
11:15 AM
Rote memorization and paper exams go hand in hand. It's unfortunate, but until your school does away with exams entirely, you're screwed.
 
I would be extremely happy for that to occur
immediately, in fact
 
You don't really want to have to solve creative problems and debug several programs in a 3-hour exam period.
 
and to throw out any and all coursework which does not start with the terms (or equivalent) "Write a program such that..."
 
Well, I don't have much experience in CS, so my opinion might not be worth much. But I recall exam questions in the compiler class which appeared to be high-level design or theory, requiring creative thought, but were actually regurgitation.
So if you attempted to solve it yourself, even getting a valid answer, it would be wrong because it wasn't what was written on the blackboard four weeks ago.
That is bad.
 
not really seeing the difference
regurgitation- regurgitation- they seem to be the same to me
 
11:20 AM
The difference is that at least you know what to expect, and they are calling a rose a rose.
 
true
 
In the digital circuit course I TA'ed, I'd try to put design questions on the exams. But that worked better because the design space is smaller. There would only be a couple ways to design the circuit, one of which would be regurgitation.
 
I would just skip examinations full stop
 
Usually most students regurgitated, half the remainder who made educated guesses were correct, and the rest drew something and then maybe scribbled it out, getting partial credit.
 
Just do it :)
 
11:23 AM
But when it comes to programs, there are too many solutions. It's impossible to grade them sanely. Unfair even to have to write the answer with pencil in the first place.
 
hence why I suggested just not having examinations, at all
 
Then how do you weed out students who just copy work?
or ask StackOverflow?
 
my university has some impressive measures to prevent copying
apparently, it's really not a problem for them at all
 
such as?
 
they have some fancy text analysis programs designed for programming languages
they check around on the interwebs, and they ask all the local code for hire agencies if they've sold
you could never get a full-blown assignment off SO anyway
 
11:26 AM
And if someone just does search-and-replace on local variable names?
 
heh, it's not that dumb
I've seen it in action and it's dependable
I mean, the University already has some programming courseworks, so they clearly believe it can be trusted
 
Copying concepts and parts of solutions is still copying. Sharing notes is copying.
 
cool :)
 
You can't prove that two functions identical except for variable names and whitespace are the product of copying. The best solution is the most likely to occur (one would hope).
 
according to my PROLOG lecturer, errors are usually the giveaway
no two students make the same mistakes in self-authored programs, but if you copy from someone, you also copy their bugs
3
 
11:29 AM
This is true.
The solution to that problem, however, is simply to copy from someone who is smart.
 
nobody writes bug-free code
besides, that's not even the point
the point is that examinations are not even remotely a reflection of a student's true skill
 
Sure people write bug-free code. Anyway at my uni the design problems came with thorough testcases.
Yes, exams are pretty overrated. In most of the engineering courses I took, they really didn't count for much. Design problems counted for more.
But copying was explicitly allowed to a degree for design problems.
 
I wouldn't be afraid of that either
 
So I don't see what's wrong with your school now, at my school they were either too lazy to look at the assignments or they just ignored it if they saw people copied stuff, that sucks!
 
I've just gone over what's wrong with it in pretty agonizing detail
that is, endless regurgitate-from-board bullshit
which is not at all reflective of the student's skill
 
11:35 AM
so what exactly do you have to learn, theoretical comp sci?
 
yep
 
Unfortunately I forgot most of that stuff already, but it's fun :)
We were allowed to take a 10 pages summary to the exam.
 
no, it's an utter waste of time
if it wasn't, you wouldn't have forgotten it
 
10 pages?! You can fit an awful lot on 10 pages! I was never allowed to bring more than 1 sheet to an exam.
I can write like 3 lines of text within a college-ruled line… little tiny diagrams too :D
 
The day I want to check out Scons is the day www.scons.org times out.
 
11:55 AM
Heh I hated the Cocke-Younger-Kasami- Algorithm table making
 
12:12 PM
still could be more elegant, but IMHO not cryptic anymore :)
 
ah nice
let me have a look
 
Also catches edge cases involving ^ and * that the original code didn't
 
i Only use references for primitive non-class types when using as out parameters, and for operator functions
for everything else (class objects) I use pointers
 
@JohannesSchaublitb But pointers can be null. I use pointers iff null is valid.
Or if the referent might change, lol oops
 
argh I accidentally hid the posts of some users, how can I unhide them?
@Potatoswatter But you didn't eliminate recursion?
 
12:19 PM
@JohannesSchaublitb, have you seen my constructor syntax question?
 
i must have missed it
 
didn't know about stdbool.h
 
@Nils Co-recursion is necessary to solve the problem. I eliminated the gratuitous recursion, though.
10
Q: Does a namespace-scope constructor definition require a class-qualified identifier?

PotatoswatterHere's something we all learned on Day 1 of C++, which we take for granted but doesn't clearly follow from the wording of the Standard. Given a class S, we can define its constructor struct S { S(); }; S::S() { … } But the Standard seems to allow this just as well: struct S { S(); }; S() { …...

 
stackoverflow.com/questions/931762/… see the answer by Konrad Rudolph, theoretically it is possible I would like to know how to do it in practice.
 
@Nils Recursion just takes advantage of the stack data structure inherent in the virtual machine of C or whatever other system.
 
12:23 PM
@Potatoswatter 12.1/1 is only for in-class constructor declarations
the text there could be clearer, but that's the intention
(in an out-of-class constructor definition the S::S does not refer to the class. it's not a class name, but it is a function name and refers to the constructor)
 
Tail recursion doesn't use the stack, so you can eliminate it more trivially. In general, converting recursion to iteration requires introducing an explicit stack structure.
Which is easy in C++ with std::stack, but more painful in C.
 
Well maybe I have to invest a bit more time into actually doing this.
 
the example that follows 12.1/1 shows an out-of-class constructor definition, but that's not related to its text
 
@JohannesSchaublitb The bastards!
But, a namespace scope constructor definition still differs from other function definitions in that it omits the return type. (Same with conversion operators and destructors.)
Where is that syntax described, then?
 
12.4 which is about destructors has that reminder: "... is used to declare the destructor in a class definition.". sadly 12.1 for constructors doesn't. but it's clear it should have. because by the rules in 3.4.3.1, a S::S in that out of class definition doesn't refer to the class
 
12:30 PM
Also I'm confused by the contradiction: 12.1 begins by saying "the constructor does not have a name" (which was the idea I'm familiar with) yet 3.4.3.1 describes how to name the constructor.
 
@Potatoswatter 7p9 allows one to omit the return type (decl-specifier-seq) for constructor declarations)
and the rule in 3.4.3.1 makes so that S::S refers to the constructor. so an out-of-class constructor definition it doesn't need a special constructor declaration syntax
that it is a constructor definition follows from the fact that the name in the declaration refers to the constructor.
@Potatoswatter yep, 12.1 is wrong.
well, not entirely
 
They should make up their minds…
 
a constructor declaration doesn't add a member name to its class
the way 3.4.2.1 makes S::S refer to the constructor is by reassociating it from the injected class name to the constructor
 
If the constructor name coincides with the injected class name, then the constructor still has a name.
 
it doesn't directly find a function member name
 
12:33 PM
Just as 3.4.3.1 says, C::C and class C::C are two different things.
 
so in a way, a constructor doesn't have a name itself. but still it can be found by name lookup
 
@Potatoswatter I don't quite understand this line
case '.': if ( *text || *regexp == '*' ) ++text; /* match anything */
 
so when 12.1p2 says "Because constructors do not have names, they are
never found during name lookup; " it is just plain wrong
 
Eh… any result of a name lookup is a name. The constructor and destructor are different in that they can't be directly called or addressed.
Well, thanks for the insight! If you wouldn't mind writing a little answer… I look like an asshole answering my own questions :vP
 
Line 48: If text or regex are equal to * increment text pointer?
 
12:36 PM
you can try to directly call the ctor: struct A { A(); }; int main() { A::A(); }
the compiler will tell you that you cannot directly call the ctor
in one weird testcase I once got comeau allow me to call the ctor
 
@Nils Yeah, that's a little wart. If the next regex character is a star, treat the current regex character as a wildcard. Then upon handling the star, go back one character and redo.
 
@JohannesSchaublitb Win!
I looked at an early draft of the standard, circa 1993, to try to figure it out. Back then, the constructor was explicitly a member function with a name coinciding with the class. It could be called normally.
 
i don't know whether they already had injected class names by that time
 
That draft also described the functional conversion notation as "calling the constructor."
I think they did… hmm
 
12:40 PM
it would cause a problem because function names normally hide class names. so the constructor would always hide the injected class name.
struct A { int A; }; // allowed
now when you say A::A, it will not refer to the constructor, and not refer to the class, but refer to the data member.
I think there is no way to refer to the implicitly declared default constructor for such a class :) you can refer to the injected class name by saying struct A::A
 
… maybe not. The word "inject" does not occur, and since there's no table of contents and so many things changed over the next 5 years, it's hard find positive evidence.
@JohannesSchaublitb Likewise, in the scope of a member function, attempting a function style conversion (constructing a temporary) would actually call the constructor on this.
 
Hmm, what is there to watch out for wrt/ rvalue references support in VS 2010 versus the standard rvalue references?
 
So that would cause havoc with a lot of code.
 
Actually, this could be a nice SO question...
 
12:47 PM
@Potatoswatter i had a discussion with James Kanze about this exact topic
 
@Nils it took me a little while to verify that it works properly. Note that "*", but not ".", will match the terminating '\0'
@JohannesSchaublitb I guess they prioritized features and things that actually make a difference for C++11. At least if it's on their radar, maybe C++13 can include a "bugfix"
 
@Potatoswatter see comments on stackoverflow.com/questions/6230448/…
now that they are finished with c++0x they have more time to think about these things I suspect
 
Well… this all also brings up the question I asked Eric Z, which is, is there any valid expression that names the constructor?
 
apart from out of class constructor definitions, you can directly refer to the constructor in a using declaration in c++0x
using base::base;
 
Yes, but that's not an expression.
 
12:56 PM
true :)
 
It contains an id-expression if I recall from the research for that question… not quite what I mean though.
Well, you don't need to call or take the address of the constructor to obtain its type with decltype, right?
 
struct A { typedef decltype( A::A ) type; }; you mean?
Probably have to = delete; a bunch of stuff to deal with the overloads.
 
Just the copy constructor :v) … and move… I think…
 
GCC complains that A is incomplete with the above snippet.
@Potatoswatter Removing the copy-c will implicitly delete the move-c as well. So only one deletion needed!
 
I'm trying std::cout << decltype( s::s ).name() << '\n';
 
1:03 PM
@Potatoswatter the problem is that you are only allowed to use such a constructor "name" in an out of class constructor definition or in an in-class using declaration.
 
@LucDanton It still says it's overloaded, and won't tell me the candidates :v(
 
Yeah I moved it out of class too.
 
so decltype( A::A ) is invalid :)
 
At first there was no A::A and after defaulting the default constructor I still get an overloaded name.
 
@JohannesSchaublitb 3.4.3.1 says the constructor is found unless it's not a valid result of name lookup
 
1:04 PM
@Potatoswatter yes but later it says that the name shall only be used in those two contexts
 
Either the constructor is found or the injected name is found, either of which makes the expression valid.
@JohannesSchaublitb Where does it say that?
 
it says at the endof that paragraph "Such a constructor name shall be used only in ... "
 
I'm personally fighting GCC on another front: I've got a functor with a pointer to member but I don't know how to overload operator()(C&& c, Args... a) such that the functor accepts both objects and (possibly smart) pointers.
Using decltype won't trigger SFINAE; any idea to trick GCC?
 
@JohannesSchaublitb Ah, thanks :vP
 
Is there such a thing as "rvalue references v3"? Google turns up some search results, but they aren't very conclusive.
 
1:06 PM
Still, one can hope for a compiler bug! LOL
@FredOverflow Probably one of the official papers. Try the WG21 site.
 
@Potatoswatter There is not a single 2011 paper with "rvalue" in the title...?
 
@FredOverflow Try 2009 or 2010
 
"funny rvalues"
 
@JohannesSchaublitb That paper was written before they invented xvalues :-)
 
i believe so
 
1:10 PM
@JohannesSchaublitb Actually, it is "funny lvalues", isn't it?
 
i believe so too
 
You seem to be a man of great belief.
 
at one time I called types to be funny rvalues because the committee said that type names are id-expressions.
 
why?
 
and the spec says that id-expressions are lvalues / ralues. typenames are rvalues according to the spec then
i too believe that a type name is an id-expression in the spec. and that the spec funnily says that type names are rvalues
 
1:13 PM
Are typenames even expressions?
 
I think the cut is to be done at primary-expression.nowhere does the spec seem to say that a type name is a primary-expression. :) but now It's too late to return back at that discussion to the committee.:) but I think it makes sense
 
@Nils: are "a$*b" or "a^*b" supposed to match "ab"?
 
@FredOverflow the question is whether every id-expression is an expression.and I think the answer is no.
but every primary-expression is an expression, I assert
 
@Potatoswatter guess so
 
@JohannesSchaublitb Well you can append () and obtain a result rvalue, so type names appear to be in the same category as function names.
 
1:15 PM
@Potatoswatter yuck, regular expressions
 
when parsing, and when it comes to promoting an id-expression to a primary-expression, for type names that promotion cannot be done.
 
Except function names are lvalues, and you can't take the address of a typename, so typenames are rvalues… yep
:D
 
I'm not really familiar with Visual Studio to create a project with external sources already existing on the file system?
 
Wow, "unified assignment operator". Interesting stuff!!
 
@wilx What are you talking about?
 
@JohannesSchaublitb Nice :D
 
@FredOverflow Lavavej describes how to write a single assignment operator that works both as move and copy assignment operator.
 
@wilx Sure, just pass by value and use the copy-and-swap idiom, right?
 
Yeah.
 
1:26 PM
Note that copy-and-swap is not always what you want for every class.
I'm pretty sure std::vector does not use copy-and-swap, for example, to achieve better efficiency.
 
Pick either of: write move + copy assignment, rely on generic std::swap; or implement swap, use copy-and-swap.
 
...or don't use copy-and-swap at all in assignment. Less exception-safe, but often more efficient.
 
@FredOverflow How is that not my first option?
 
Depends on what you want. If you want exception-safety, use copy-and-swap. If you want uncompromised efficiency, don't use it.
 
Can you show me an exception safe swap that can't be implemented as a move assignment instead?
 
1:30 PM
Note that I almost always use the copy-and-swap idiom, because less code usually means less chance for bugs.
@LucDanton I don't think we're on the same page here.
 
@FredOverflow Using or not using copy and swap is orthogonal to making the strong exception guarantee. If you have a strong swap, you can write a strong move assignment.
Not so sure about weaker guarantees.
Ditto regarding the nothrow guarantee. The strong guarantee can also be implemented in a move assignment.
Look at it that way: move assignment is half the work of swap.
You can implement either of those and then implement the other one in terms of the first.
 
swap only moves around
 
@JohannesSchaublitb True. I suppose what I said only applies for nothrow destructors.
 
im sorry.i didnt read the backlog
i just uttered something into the channel
 
It's possibly relevant.
 
1:36 PM
posted a new comment on cpp-next.com: "“Except for enums, every value with a name is an lvalue.”. I know I’m going to annoy you by this, but I want to inform the innocent reader that integer, pointer and member pointer template parameters aren’t lvalues either."
with these most recent insights I should have added "type parameters" to the list. aaahaha
 
@JohannesSchaublitb it's way too easy for idiots to generalize
what about member function names?
 
They're not a valid expression, are they?
 
I suppose not… guess that disqualifies from being values.
 
2:01 PM
@JohannesSchaublitb this is not an lvalue, either.
 
@FredOverflow it's a keyword though, not a name
 
@Potatoswatter oic
 
Well, does that still disqualify this as being the name of the value that it yields?
What's in a name?
Sorry :(
 
Well… it doesn't come from name lookup. Most languages do make their equivalent a name…
You could say the same for eg nullptr too, or even true, false, numeric macros…
 
2:21 PM
@FredOverflow this is not a name
 
main is an lvalue but using it as such is UB :D
 
you can say sizeof(+main) and sizeof(main, 0)
 
WTF?
Just looked it up, main shall not be used. I suppose that means ODR-used.
 
i didn't use it. i abused it
 
Using it as an lvalue would ODR use.
 
2:25 PM
lol
no. the second example uses it as an lvalue
 
But what does unary + do to a function name?
 
it provokes a function to pointer conversion
sizeof(main()) is also valid if you declared it without parameters
and in C++ a function is not converted to a pointer if you call it (unlike c, where the conversion is always done unless a & is sticked before it)
 
I stand corrected. And aghast.
 
2:50 PM
the flagging system is teh shit
i flagged my question saying "It's too confusing to me whether this question belongs on Stackoverflow.SE or Programmers.SE. Stackoverflow has way more licensing+lgpl questions than Programmers. And according to the FAQ my question is ontopic. Requesting a good decision on this. Thanks."
and they said that the flagging was "Invalid"
 
hi! I have an interview question. It is an algorithmic question which I had to write in C++. I was wondering if this is the right place to discuss it?
 
@user639309 Depends on the question.
(Your question, not the interview question.)
 
This is certainly the right place to ask a question about your question about their question.
 
My question is simple..an this be done in O(nlogn) time?
**can
 
2:54 PM
Um, usually when referring to elements of an array, you specify their values, not their addresses. Your example is very hard to read.
 
I see. Well you can also find the description here:geeksforgeeks.org/forum/topic/check-for-triangular-triplet
I am also modifying my post to make it more readable..
 
The space complexity doesn't make sense because O(N) is required for the array in the first place. If an in-place algorithm is desired, that's not a big-O matter.
Sorting can be done in-place in O(N log N) time, so why is it not an option?
 
As far as I remember, the interviewer was clear about 2 things. I am not allowed to copy the array and I am not allowed to modify it.
 
01:00 - 15:0015:00 - 00:00

« first day (309 days earlier)      last day (4641 days later) »