The Student Room Group

Scroll to see replies

Ape Gone Insane
Something interesting on False Anger.

If someone speaks angrily THEN slams their fist on the table, the anger is false.
If someone slams their fist on the table THEN speaks angrily, the anger is true.

I think I got the order right :awesome:

If someone's figure is pointing in another direction whilst they are directing their words towards you, they are most likely lying because their brain is working so hard to construct the story the brain isn't telling the finger to point at you rather than the door.


Episode on 'Lie To Me', the one about the murdered student at a really posh school and the teacher who sat an exam for her did this. :awesome:
Ape Gone Insane
You're agreeing with me :facepalm2:

And people do it. People do it all the time. Teachers are the worst.


Although I can think of one counterexample:
http://en.wikipedia.org/wiki/Shoe-banging_incident

The most reliable accounts state that Khrushchev banged his shoe after speaking angrily.
What about people who slam their fists and speak angrily at the same time?
Ape Gone Insane
I'm off.


I'm going to start using the number of times you say this before actually doing so as an entropy source for a crytographic RNG. :p:
TheUnbeliever
I'm halfway through the second of 4 questions of 4 collections of questions. :sigh:


I really shouldn't be doing this while you work but since you are on TSR anyway consider this snippet of code written in C:


// \u000A is the newline escape sequence since \u00=NULL and \u0A=Lf

int f() {
printf "Hello thar\u000A";
return 0;
}


What will you see when you compile and run this function? :wink:
ukdragon37
I really shouldn't be doing this while you work but since you are on TSR anyway consider this snippet of code written in C:


// \u000A is the newline escape sequence since \u00=NULL and \u0A=Lf

int f() {
printf "Hello thar\u000A";
return 0;
}


What will you see when you compile and run this function? :wink:


That shouldn't compile. (Even ignoring the absent brackets for printf and the non-standard entrypoint.) What are you trying to get at?
Bed. I'm no longer working, I'm simply staring at the screen.
TheUnbeliever
That shouldn't compile. (Even ignoring the absent brackets for printf and the non-standard entrypoint.) What are you trying to get at?


Why doesn't it? :ninja:
ukdragon37
Why doesn't it? :ninja:


The UCS is designed to only be used with a certain range of characters - the precise details of which I forget, but it excludes almost all the normal characters and certainly newline. Essentially, the standard expressly forbids the usage of the universal character \u000A.
TheUnbeliever
The UCS is designed to only be used with a certain range of characters - the precise details of which I forget, but it excludes almost all the normal characters and certainly newline. Essentially, the standard expressly forbids the usage of the universal character \u000A.


Aww you are so near yet so far! :p:

I'll let you sleep for now, answer tomorrow! (tonight)

Unless you are desperate...
ukdragon37
Aww you are so near yet so far! :p:

In what way?
TheUnbeliever
In what way?


You've got the "start" of the reason why it won't compile, but it's not the whole thing.... That is, if you wanted to printf most unicode characters other than newline it should work. But in this case there's an added bit to the reason.
ukdragon37
You've got the "start" of the reason why it won't compile, but it's not the whole thing.... That is, if you wanted to printf most unicode characters other than newline it should work. But in this case there's an added bit to the reason.


Be more explicit, please. The C99 standard (since the UCS is non-existent in C89/C90) explicitly defines a set of characters which it will print. 00A0 is not in this set of characters. Consequently it is not a valid UC and the program will fail to compile as it's an invalid escape sequence. :confused:
TheUnbeliever
Be more explicit, please. The C99 standard (since the UCS is non-existent in C89/C90) explicitly defines a set of characters which it will print. 00A0 is not in this set of characters. Consequently it is not a valid UC and the program will fail to compile as it's an invalid escape sequence. :confused:


UGH sorry I just realised something, which is incredibly embarrassing - just shows how noob I am :o:

I'll just say you are right in this case.

You see, we were using four different languages all at once when we were in the computing society squash. I just realised this example was in fact written in Java X_X And I was trying to make it work around C.

It will fail to compile in Java for a totally different reason though :p:
ukdragon37
You see, we were using four different languages all at once when we were in the computing society squash. I just realised this example was in fact written in Java X_X And I was trying to make it work around C.


:p: You're fairly unlucky in that you chose the one language I have actually read the standard for cover-to-cover. When I doing my osdev, in C, it was useful to know what was implementation-defined and what was undefined behaviour - not to mention I reimplemented a substantial portion of the standard library myself.

It will fail to compile in Java for a totally different reason though :p:


Out of curiosity, what is it? I don't know Java at all - I can feel my way around from it's similarity to C#, but don't actually know the language.
TheUnbeliever

Out of curiosity, what is it? I don't know Java at all - I can feel my way around from it's similarity to C#, but don't actually know the language.


The trick is in the comment line. The Java compiler will replace all character escape sequences with the real characters, like a predefined C preprocessor with all the unicode characters. Thus the first line will become:

//
is the newline escape sequence since \u00=NULL and \u0A=Lf


Which obviously not very ingestable to the compiler :rolleyes:

The "\u00=NULL and \u0A=Lf" bit is pure pish-posh. It was a hint to tell you it was the comment line that was at fault :p:

In the Squash we were doing puzzles in JavaScript, Java, C(++) and ML. People were arguing over:

Will "(a++)++" compile?
Will "++(a++)"?
How about "(++(a++))++"?
ukdragon37
In the Squash we were doing puzzles in JavaScript, Java, C(++) and ML.


You may find this quiz interesting. There were two harder versions, which sadly seem to have disappeared into the ether. The may be on the Internet Archive, but it's down for maintenance.
TheUnbeliever
You may find this quiz interesting. There were two harder versions, which sadly seem to have disappeared into the ether. The may be on the Internet Archive, but it's down for maintenance.


I don't know whether I should take this patchwork approach to learning C - I think it might be worth doing it from the ground up properly and if that means I'll only have time when it comes around in the course then so be it.

Done with maths, now doing my FCS supervision work before I go to sleep.
ukdragon37
I don't know whether I should take this patchwork approach to learning C

Definitely not, IMHO - there are rather too many of these little bear traps described as 'implementation defined' or 'undefined behaviour' (i.e. it's perfectly legal for it to compile without issue and then play a game of tic tac toe, start WWIII or microwave your goldfish - or any one of these at random). I'd recommend learning it as you would any other language, and then read the standard.

I'd also urge you to consider learning C++ rather than C unless you specifically want to do systems development. C++ still suffers from those problems, but there are nicer tools to work with in the standard library and Boost.
TheUnbeliever
Definitely not, IMHO - there are rather too many of these little bear traps described as 'implementation defined' or 'undefined behaviour' (i.e. it's perfectly legal for it to compile without issue and then play a game of tic tac toe, start WWIII or microwave your goldfish - or any one of these at random). I'd recommend learning it as you would any other language, and then read the standard.

I'd also urge you to consider learning C++ rather than C unless you specifically want to do systems development. C++ still suffers from those problems, but there are nicer tools to work with in the standard library and Boost.


That's a long way away :yawn: not until next year.

I can see I'll be good at none of the languages taught, whereas everybody seems to be competent already at at least one.

Maybe I should switch to maths :s-smilie:

Latest