Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!news From: C0361@univscvm.csd.scarolina.edu ( Thomas Jenkins) Newsgroups: comp.lang.pascal Subject: Why does this work in TP ? Message-ID: <25295@adm.brl.mil> Date: 18 Dec 90 18:48:47 GMT Sender: news@adm.brl.mil Lines: 72 The program below has an unusual feature. Is this considered a legal OOP ability? See the question below after looking at the code. PROGRAM ObjectTest ; USES CRT ; TYPE DumbOBJ = OBJECT PROCEDURE MethodA ; PROCEDURE InMethodA ; END ; { DumbOBJ } VAR obj : DumbOBJ ; PROCEDURE DumbOBJ.MethodA ; PROCEDURE InMethodA ; BEGIN { DumbOBJ.InMethodA } WriteLn ( '...In InMethodA!' ) ; END ; { DumbOBJ.InMethodA } BEGIN { DumbOBJ.MethodA } WriteLn ( 'In MethodA.' ) ; Write ( 'Calling nested method...' ) ; InMethodA ; END ; { DumbOBJ.MethodA } BEGIN WriteLn ( 'Testing nested methods.' ) ; obj.MethodA ; obj.InMethodA ; END . If you compile the above code, the output looks like: Testing nested methods. Inside MethodA. Calling nested method......In InMethodA! ..In InMethodA! Isn't this a violation of scopeing rules? I notice this behavior in a large object system and boiled it down to this. Anyone up to explaining this behavior? Is this legal or a bug/feature/undocumented feature ( <-this last one because I can't remember reading this as legal )? tom THOMAS E. JENKINS, JR. +--------+ FROM SHOE +--------+ |"IS THE COMPUTER STILL GIVING | PROGRAMMER, | YOU TROUBLE?..." | UNIVERSITY OF SOUTH CAROLINA |"NO, NOT ANYMORE..." | C0361 AT UNIVSCVM.BITNET |"WHAT DID YOU DO?..." | C0361 AT UNIVSCVM.CSD.SCAROLINA.EDU |" I TURNED IT OFF." | +-------------------------------+