too simple a question : forward declaration? (also, how to make Python segfault!)

Peter Abel p-abel at t-online.de
Thu May 15 13:51:33 EDT 2003


Recursion loop is one thing, that should be avoided. It can't be
solved in any language. It's obviously a programming fault.
Forward declaration is at my opinion something for compiler languages.
It helps the compiler in an early state, so it knows what will come
further.
I think in interpreted languages forward declaration can't be done in that
sense as it is done in compiler languages.
I guess it can only be done by programming techniques.

I'm not quite sure, but maybe the following code example goes that direction.
>>> class foo:
... 	class_var='Je suis foux'
... 	def __init__(self):
... 		self.bar_name=bar.class_var
... 	def show(self):
... 		print self.bar_name
... 		
>>> class bar:
... 	class_var='Iam bar'
... 	def __init__(self):
... 		self.foo_name=foo.class_var
... 	def show(self):
... 		print self.foo_name
... 		
>>> f=foo()
>>> f.show()
Iam bar
>>> b=bar()
>>> b.show()
Je suis foux
>>> 
maybe that helps
regards Peter




More information about the Python-list mailing list