PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Computer Folklore     

What is it's scope


VPN Service Provider

CSE 143 and professor Kelsey both give me points off for using Loop. 14058
snips On Mon, 04 Apr 2005 21:00:02 +0000, The Ghost In The Machine Not if you're writing C or C++; it would be...

In comp.os.linux.advocacy, JeffRelf wrote on 05 Apr 2005 12:25:34 GMT

CSE 143 and professor Kelsey both give me points off for using Loop
Hi Kelsey, Re: int main() { printf( "Hello, world-n" ); return 0; } That's a compiler error... Quickly resolved. Also, should be: main() { printf( "Hello, world-n" ); } if ( ptr = (char *)malloc(100 ) ) free( ptr...

For g++-x86 it's also left-to-right. However, that's probably because the LALR Debt Reduction for left() to some sort of abstract expression is done first (since it's seen first).

Yes, that's one way to verify ordering -- buttuming the debugger's any good.

The returned value is a templated object subject to the usual copy constructors and buttignment operators. (Note that most don't know or don't really care about the typedef aliasing details myself.)

If I'm not mistaken, one could declare the following:

std::string generateName() { char tmp32; timet now;

time(&now);

snprintf(tmp, sizeof(tmp), "name%lu", (unsigned long) now);

return tmp; }

int main() { std::string name = generateName(); return 0; }

and several things will happen.

1 The tmp buffer is constructed on stack, as one might expect.

2 Since tmp, a char * char , is obviously not the same as point the most likely happenstance is that a temporary and initialized in accordance with standard C rules. However, some other conversions might also be attemptable; I'd have to experiment and-or look around for possibilities.

on compiler this can either be done by buttignment (using an implicit argument) or the structure is copied into a heap-allocated affair, whose pointer is then returned. I would hope the former, for performance reasons.

Microsoft wants C++ to replace C, which is fine with me
Hi Spooky ( and Arkady Duntov ), Re: Why I use MSC++ instead of MSC, I think Microsoft wants C++ to replace C, which is fine with me, But that doesn't mean...

4 Whatever the return form, the object is either discarded (if for some reason someone forgot to buttign the result to something!) or copied (again?) into its final resting place, in this case 'name' on the caller's stack frame.

A brief analysis of the x86 buttembly code from the above function suggests that it indeed is constructing a 24-byte something and pbutting it into generateName(). Without more analysis I can't say precisely what it is doing.

CSE 143 and professor Kelsey both give me points off for using Loop. 14059
Hi Spooky ( and professor Kelsey ), Re: Me getting points off for using Loop() in CSE 143, Because they, like professor Kelsey and you, can't...

One problem with arrays is that C (and C++, for various reasons) processes them as pointers in many contexts. This is one reason

const char * generateName() { char tmp32; ... return tmp; }

has problems; the returned pointer is where tmp *used* to live (its stack frame is now gone), and C doesn't bother to pbutt size information back to the caller on how big the array is supposed to be. In Pascal, for example, one couldn't even do this; one would have to do something along the lines of

program foo; type tmpString = array1..32 of char; var newname : tmpString;

function generateName : tmpString; var time: something; tmp: tmpString; begin (* OK, so ISO Pascal doesn't really have a time() equivalent. :-) *) ... return tmp end;

begin newname = generateName; writeln(newname) end.

(Apologies for any typos; my Pascal's very rusty.)

-- It's still legal to go .sigless.


Linux | Previous | Next

CSE 143 and professor Kelsey both give me points off for using Loop

Linux Advocacy Newsgroups

Quiz time for Bonzo