🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Mark Purtill Thu, 07 Mar 1991 17:38
A possibly stupid proposal
#917
Author: Mark Purtill
Date: Thu, 07 Mar 1991 17:38
47 lines
2394 bytes
I often get compile error when I do things like this:	

	for( int i=0; ...; ...) {
		...
	}
	...
	for( int i=0; ...; ...) {	// ``i redeclared'' error here
		...
	}

	While this is admittedly fairly dim of me, I'd rather fix C++
than learn to avoid the error, so I propose that redeclarations be
allowed.  
	The old object would be destroyed (if necessary) and the new
one created.  To allow the destruction of an object without creating a
new one, I propose allowing the declaration 'void foo'.  Any attempt
to access foo would be an error.  'static' and 'extern' objects would
still give errors if you tried to redeclare them.
	This doesn't break any code, since currently any code that
this would apply to would have the redeclaration error now.  In
particular, code like:

	int foo ;
	...
	{    int foo ; 		// the outside foo is NOT destroyed here.
	     ....
	}
	    
would still work the same way as it does now -- the interior 'foo'
would shadow, not destroy, the exterior 'foo'.
	In addition to allowing each 'for' to declare its own 'int i'
(which would presumably be appreciated by those who think that the
scope of those variables should end at the end of the 'for' loop),
this would also allow more control over when auto objects were created
and destroyed;  I seem to remember postings a while back that wanted
this.  (So don't judge the proposal simply on the basis of my silly
rationale.)
	On the down side, it would allow some authentic errors to get
through, causing confusion.  But probably not much more confusion than
shadowing already does.
	Opinions (even if only "that's the stupidest thing I've ever
seen") welcome.  Flames (as in "you're an idiot for having proposed
this") to /dev/null.
	
^.-.^ Mark Purtill         purtill@dimacs.rutgers.edu         (908)932-4580 (O)
((")) DIMACS, P.O. Box 1179, Rutgers U., Piscataway, NJ 08855 (908)220-6905 (H)
********** Note new area code!  We are now (908) rather than (201)!  **********
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads