« first day (451 days earlier)      last day (4496 days later) » 

8:00 PM
Read a symbol to the stack and check if any production matches the latest symbols. If yes, then replace those symbols with the new production (and execute a semantic action).
Of course this is the non-efficient description.
 
@JohannesSchaublitb About the same reason that the following works, my guess:
struct A { A(int a, int b, int c); };
A a{1, 2, 3};
 
surely that can't be any production, because many productions might be invalid contextually
 
@JohannesSchaublitb You see, the outer braces are the 'uniform initialization' way to specify constructor params. The param happens to be of type initializer_list, which itself allows initialization from {....}
Disclaimer: I haven't opened the Holy Standard on it, I just figured what I'd think made sense
@JohannesSchaublitb Is there a passage in the standard that prohibits this? I mean, it can't possibly be that inializer_list cannot be implicitely constructed :)
 
@DeadMG Oh yes, there's some checking for that. Usually there's a table describing state changes, and looking up the change for such invalid productions results in a jump to an error state.
 
ok
so right now, I have a pretty simple LR grammar, which would be
and I'm just trying to imagine what the LR code is to match it
 
8:09 PM
@DeadMG that's a funny grammar. Do you really only allow identifiers as rhs operands to +/-?
 
no, it's obviously a trivial grammar
 
Our LP class left LR to the end and we didn't have time for playing with them much :( It was mostly just building state tables.
 
phew, good
 
@sehe I'm not so hot on grammars, but it looks like it can take a lhs identifier to me: {{ident} + ident}
 
@DeadMG My gut says: expr = expr + ident | indent --> expr = ident ('+' ident)*
But I'm spoiled by Spirit and have forgotten all the 'proper theory' years ago
 
8:11 PM
that grammar allows for arbitrary sequences of addition and subtraction
 
@DeadMG With only identifiers.
 
@FredOverflow Ah, automagic decay to a pointer-to-self...
 
yes
but to do more than that, I'd need to have added parenthesis, which was needlessly complex
for the example
 
@KerrekSB not as bad as array to pointer decay methinks :)
 
@FredOverflow The latter is predictable, and avoidable because you don't need to use arrays. The former would be an unmitigated disaster.
 
8:14 PM
@KerrekSB Honestly, I don't think so, but we'll never know for sure :)
 
@KerrekSB: I doubt it would be that bad
 
@FredOverflow you could ask Bjarne why he switched
 
@Ambeco I did, and he couldn't remember anymore :(
 
May I ask a question now?
 
sbi
8:17 PM
@Charlie Did you read the newbie hints, linked from the right-hand panel? (They answer that question.)
 
@Charlie: Of course, it's just not guaranteed that anyone answers ;)
 
@Charlie Sure, why not?
 
I just didnt want to be accused of butting in again
Im trying to use statfs
and to figure out how to use it correctly I have made a small bit of code
 
@Charlie The internet dictates: don't ask to ask
 
8:19 PM
@Charlie Sry bout that, didn't know you're new here :)
 
struct statfs fs;
statfs ("/", fs);
printf("blocksize = %d\n", fs.f_bsize);
 
@Charlie You mean, fstat?
 
error is undefined reference to _statfs
I am trying to get the filesystem blocksize using statfs
 
why, you're not trying to compile this on Visual Studio perchance?
 
noooooo
gcc (yes i am using the C (I hope this doesnt spark off a big debate))
 
8:21 PM
@Charlie shouldn't it be statfs("/", &fs);?
 
I gave that a go and it gave me the same error
 
@Charlie "undefined reference" is a linker error
 
@Charlie I don't think you got the same error.
 
@DeadMG here's what I believe the table for that would look like: pastebin.com/0tYsMCqM
 
sbi
@KerrekSB No, it stands for State bank of India.
 
8:22 PM
so i have include stat, statfs, statvfs , stdio and types
 
@Charlie How about you paste a complete example at ideone?
 
it doesn't matter what the table looks like
my C++ compiler will not accept a table as input
it accepts C++
 
ok @FredOverflow give me a minute
 
I thought you were writing a compiler compiler.
 
:2330919 #include <sys/vfs.h>    /* or <sys/statfs.h> */
#include <stdio.h>

int main()
{
    struct statfs buf;
    if (0!= statfs("/", &buf))
        perror("statfs");
    else
        printf("f_bsize: %d\n", buf.f_bsize);
    return 0;
}
This works for me.
 
8:23 PM
I AM
but it's not table-driven
 
0
Q: c++ inheritance syntax

user1141665To all you cpp experts, In c++ inheritance, class B : public A { }; I am just curious why is the keyword public needed here? Does it mean something?

not a real question? lol
 
I warn you though I am using a version of linux that is completely customed and stripped
 
Prints f_bsize: 4096
 
@DeadMG But that won't be as efficient, I believe.
 
it's more of an automated hand-written parser generator, as it were :P
sure it will
I can use the hardware stack instead of an explicit stack, I can take and return whatever I want as parse function arguments
 
8:24 PM
You could make it a recursive ascent parser. But I've only heard of those beasts, never read a lot about it.
 
@sbi Oh, that was my second guess.
 
sbi
@FredOverflow That should be reopened and properly closed as a dupe.
 
@Charlie Have you tried my code? See above
 
@RMartinhoFernandes They're table-driven, just written with each state as a function
 
@sbi agreed
 
8:25 PM
I was hoping to approximate something much more human-readable
 
im just copying to and from now
its on a virtual machine so i have to ftp everything in and out
 
@Charlie The worlds last VM without clipboard integration or SSH access
 
@DeadMG Oh, I see.
Then what was your doubt?
 
i hate it!
 
well
 
8:27 PM
@FredOverflow ideone.com/MBh6p
 
@Charlie If it's networked, ssh -t networkedbox vim test.cpp, :put|w|make test|!./test done
 
fundamentally, I doubt that I actually understand how it works :P
 
Haha, lol.
 
@sehe it is so stripped that you cant do much with it
 
but you know what?
I think I might have made a mistake
 
8:28 PM
@Charlie Woah overkill includes
 
I suppose each function consists of reading followed by a switch to decide what to call next.
 
@Charlie Well, it seems to work: blocksize = 4096
 
I figure that maybe LR is what I think of as the "obvious" thing to do
 
yeah I know that, i was adding more to see if i had missed something out
 
and LL is the "dumb" thing to do
 
8:29 PM
LL always felt more natural to me.
 
eh
 
@FredOverflow so I have tried to compile that code and it gives me error: storage size of buf isn't known
 
@DeadMG Shunting Yard + operator precedence. In practice the grammar would be like
expr : factor [*|/] factor | factor;
factor : term [+|-] term | term;
term : unary_op simple | simple;
simple : '(' expr ')' | literal | variable;
 
uh, I already have a practice grammar
 
Typed that up real quick, so forgive the many typos
 
8:31 PM
@Charlie buf? What buf? There is no buf in your code.
 
sbi
One more reopen vote here, please, so we can properly close it as a dupe.
 
the code you sent me
 
@sbi It's five for reopen
 
@Charlie I didn't send you any code.
 
oh sorry i meant @sehe sent me
 
8:32 PM
@sbi 1 made
 
sbi
@DeadMG Damn, I thought it's only three. I never remember that. Sigh.
 
@sbi First close vote in.
 
delete and undelete is three, close and unclose is five
 
sbi
@RMartinhoFernandes One more close votes, please...
 
but you can usually count on finding more than one vote in this channel at this time
 
8:33 PM
@sbi I voted to close as duplicate of a FAQ.
 
@sbi Hey! Stop plinking me with your countdown!
 
sbi
@FredOverflow If that is not the one @Björn linked to, I'm afraid that was two late.
 
@Charlie was there a question, if so, please restate, I've missed it + can't find it
 
sbi
Oh, the robot noticed. Evil grin.
 
This is really annoying me as both of them work on my desktop
 
8:34 PM
@sbi Björn didn't link to a FAQ.
 
@sehe sorry man, I accidently tagged the wrong person, however that code you sent me didnt work on my stripped out virtual box but does on my desktop! Argh
 
sbi
@FredOverflow I'm afraid there already were 3 close votes before you came. You could edit the question, though, after it's closed, and put the FAQ atop.
 
It's okay to have more than one dupe proposed. They will be both shown in the "Possible duplicates" banner.
 
int main() {
}
 
@Charlie can you do uname -a; gcc -v inside that box?
 
8:36 PM
anyone want to bet what the outcome of compiling this program is with Visual Studio?
 
@DeadMG Success?
 
ill take a look now
 
@DeadMG should work
 
actually, you get an intellisense error, telling you that main is not compatible with main, defined on line 1
 
@DeadMG Depends on compiler options and language mode. C99 or C++03?
 
8:36 PM
VS supports C99?
 
@DeadMG bwuhahahaha epic fail
 
I know VS is thoroughly broken, but really, it can't compile even less than Hello world?
 
@DeadMG erm,... I assume so.
 
@sehe gcc v 4.4.3, i 686
 
@DeadMG Ah, but it compiles?
IntelliSense for C++ is just nuts.
2
 
8:37 PM
actually, it does, which kind of spoiled my joke, since strictly speaking I asked what the outcome of compilation was
 
@RMartinhoFernandes intellisense was a dork, now they've given it 'semi-compile' powers so it can hog more resources
@RMartinhoFernandes but not of the 'pea-' variety
@Charlie sorry, nothing special there, (but it is also quite stripped info); uname -a; gcc -v lists more info, I can tell you that. Oh wait, you're ftp-ing it to your facebook account
 
huh?
how can i send the output of that command to a text file?
 
Add > file to it.
 
haha i figured that one out
 
aaah, Unix scripting
 
8:41 PM
I hate thinking out loud
 
"Did you remember the special character that means what you meant?"
it's as terribad as regexes
 
@DeadMG Come on, > is like, the easiest to remember.
It's like an arrow from the command to the file.
 
cmd.exe has > too
 
And C++ has << :)
 
aaargh
I think VS lost all my changes when my machine hard-locked :(
 
8:43 PM
I still can't get how can I safely convert Foo** to Bar** =\
 
@RMartinhoFernandes Sure, that one isn't too bad.
 
I want generic types constraints from C#
 
Wow, Sprint is still sending me emails along the lines of "Dear robjb null... "
 
@Abyx Sounds risky.
 
I wonder if they ever catch it.
 
8:44 PM
@Abyx You can't.
 
well i think it is safe to say my hunt to figure out statfs is over
 
@robjb www.thedailywtf.com
 
I can use c-style cast, but I want guarantee that it will be upcast
 
You cannot safely cast a Banana** to a Fruit** because a bowl of bananas is not a bowl of fruits.
 
I want cast Derived** to Base**
 
8:46 PM
Yes, exactly.
 
no, you can't do thateither
 
9
A: Conversion between Derived** to Base**

FredOverflowIt's basically the same reason why a bowl of bananas is not a bowl of fruits. If a bowl of bananas were a bowl of fruits, you could put an apple into the bowl, and it would no longer be a bowl of bananas. As long as you only inspect the bowl, the conversion is harmless. But as soon as you start ...

 
hazar
 
> If there was a conversion from Derived** to Base**, you could put a pointer to an apple were the type system promised only a pointer to a banana could exist. Boom!
 
statvfs worked
 
Xeo
8:48 PM
@sbi, time for your quasi-classes pdf: stackoverflow.com/questions/8810224/…
 
however i completely disagree that the virtual pc has a blocksize of 4096
 
Xeo
@Abyx Are you at it again? I thought we told you you can't do that already.
 
yep
 
sbi
@Xeo Go for it!
 
but in my case, I can (and should) do it.
 
8:49 PM
@Abyx No, you really, really, really shouldn't.
 
Hmm, a Rectangle deriving from an Area? Crazy inheritance FTW.
 
Wait, what?
 
In fact, you should never, ever create a pointer-to-pointer unless interoperating with a legacy API, that shit's just terrible
 
@Abyx Everytime you cast a Derived** to a Base**, a kitten dies.
 
A rectangle has an area, it is not an area.
 
8:50 PM
it's "a start-up dies", foo
 
@DeadMG About to submit
 
@EtiennedeMartel But inheritance.
 
sbi
@FredOverflow Actually, you're wrong. A bowl of bananas is a bowl of fruits.
 
@sbi I'm pretty sure that as soon as you say "I'm going to add an Apple" then that breaks down.
 
@sbi A bowl of fruits allows putting apples in it, but a bowl of bananas does not. Hence a bowl of bananas is not a bowl of fruits.
 
8:51 PM
@RMartinhoFernandes Inherit from ALL the classes!
 
I have a legacy code which does the same with c-style cast. Now I want to do it in C++ way.
 
the C++ way is not to do it at all
 
@Abyx Well, just try all the possible casts and see how the compiler responds ;)
 
@FredOverflow A bowl of bananas in a locked glass vault is a bowl of fruits in a locked glass vault.
 
Xeo
@Abyx Don't. Refactor. Burn it. Whatever you choose, do not use a double-pointer and try to cast it.
 
8:52 PM
@RMartinhoFernandes In what way is a Derived** locked behind glass?
 
sbi
@FredOverflow Not in OOP, but in my household I can put a bowl of bananas on the table and tell the kids it's a bowl of fruits. (I know they don't mind it being all bananas.)
 
@Xeo I'm refactoring now. And I wrap this T** into a class
 
Yes, as long as you only "read" from the bowl, it's alright.
 
Xeo
@sbi Yeah, in real life you can also put an apple in there without it exploding in your face.
 
@sbi But if they put an apple in it, kittens die! Have you warned them about it?
 
8:52 PM
@sbi Bananas are great.
 
Xeo
Now imagine if it would also explode in your face in real life. Would teach kids to seperate their garbage!
 
@EtiennedeMartel You're telling that to a gorilla.
 
@RMartinhoFernandes Oh, right, I forgot about that.
 
sbi
@RMartinhoFernandes No kitten dies when they do that in my household. (That was my point. The analogy doesn't really work.)
 
8:53 PM
@sbi Do you even have kittens in your household?
 
@Charlie in a completely simplistic move, how about: preprocess the darn thing and hope for the best in terms of libc/syscall compatibility ideone.com/uuqcV
 
well i think statvfs worked
 
sbi
@RMartinhoFernandes I did not write "No kitten dies in my household when they do this", and I deliberately did not write that.
 
I just find it hard to believe the blocksize is 4096
 
@sbi Then how can you know no kitten dies?
 
8:54 PM
and i cant find a command line tool to give me blocksize
 
@Charlie Ah I was away, preprocessing. Note, nowhere does it say that it returns the actual blocksize. You want an IOCTL instead. Let me google that for you
 
When I drove here last Sunday, I saw a dead kitten on the road. I bet it was because someone somewhere placed an apple on a bowl of bananas.
 
Had the kitten died long ago? Was it a static_cat?
 
sbi
@RMartinhoFernandes And if I had a kitten in my household, and it would not die if someone put an apple into a bowl of fruits, how would I then know no kitten died??
 
@Charlie: here comes
    unsigned long long size;
    int fd = open("/dev/sdx", O_RDONLY);
    ioctl(fd, BLKGETSIZE64, &size);

    std::cout << size << std::endl;
 
8:57 PM
What would a reinterpret_cat do?
 
O shute, wrong IOCTL, i'm sure blocksize is there to
 
well... I think static_assert(std::is_base_of<T, X>::value, "T must be base class of X"); is enough
 
@Abyx It's still not safe if you return a Base** somewhere.
@EtiennedeMartel Serve as a diplomat between humans and cats.
 
@Charlie blockdev --getpbsz /dev/sda
 
@sbi This is getting philosophical. If a kitten dies outside of your house, can you notice its demise?
 
8:58 PM
it will be more safe than existing code.
 
Xeo
If no woman is around a man to hear him say something, is he still wrong?
3
 
@sehe that snippet has me cross eyed
 
@Xeo A man is never wrong.
 
@FredOverflow I think after a few months you will notice the smell.
 
@Xeo If a tree falls on a woman, does it make a sound? Actually, the real question is why the hell was there a tree in the kitchen?
 
8:59 PM
@FredOverflow Unless a woman is around. "Do I look fat?"
 
@FredOverflow Schrodinger would be annoyed with you calling that 'philosophical'. That's physics for you. (Bordering on the ludicrous, but physics.)
 

« first day (451 days earlier)      last day (4496 days later) »