Re (2): [Oberon] identity of two VARs
David, d> .... SYSTEM.ADR(source) ... will necessarily differ from SYSTEM.ADR(target), since the two locations are disjoint. I was allowing the possibility that a client invokes Identical(astring, astring). I'm missing a subtlety. source[0] is where source begins and target[0] is where target begins. So how can (SYSTEM.ADR(source[0]) = SYSTEM.ADR(target[0])) differ from (SYSTEM.ADR(source) = SYSTEM.ADR(target))? Perhaps an example? Thanks, ... Peter Desktops.OpenDoc http://carnot.pathology.ubc.ca/
I'm missing a subtlety. source[0] is where source begins and target[0] is where target begins. So how can (SYSTEM.ADR(source[0]) = SYSTEM.ADR(target[0])) differ from (SYSTEM.ADR(source) = SYSTEM.ADR(target))?
Oberon is garbage collected and type-safe, so arays are not just contiguous blocks of memory, but also have type information which contains the length, for example. This allows the runtime to do runtime array bound checking. The (global) source variable is internally a pointer to that array structure on the heap and not necessarily identical to the beginning of the data (source[0]). For arrays not containing other pointer elements, a SysBlk is used to allocate an array on the heap. (see Pieter Muller's dissertation, http://e-collection.ethbib.ethz.ch/ecol-pool/diss/fulltext/eth14755.pdf, p. 169). Local variables use different structures. Therefore, SYSTEM.ADR(source) and SYSTEM.ADR(source[0]) can differ depending on how the array is allocated (stack/heap) and the compiler interprets 'source' without array indexes.
Perhaps an example?
as you can see from the example below: SYSTEM.ADR(heap) # SYSTEM.ADR(heap[0]), but SYSTEM.ADR(global) = SYSTEM.ADR(global[0]) and SYSTEM.ADR(local) = SYSTEM.ADR(local[0]): MODULE AddressTest; IMPORT AosOut, SYSTEM; TYPE H = POINTER TO ARRAY OF LONGINT; VAR global : ARRAY 8 OF LONGINT; PROCEDURE Test*(par : ANY) : ANY; VAR local: ARRAY 8 OF LONGINT; heap: H; BEGIN NEW(heap, 100); AosOut.String("SYSTEM.ADR(heap)= "); AosOut.Int(SYSTEM.ADR(heap), 0); AosOut.Ln; AosOut.String("SYSTEM.ADR(heap[0])= ");AosOut.Int(SYSTEM.ADR(heap[0]), 0); AosOut.Ln; AosOut.String("SYSTEM.ADR(global)= "); AosOut.Int(SYSTEM.ADR(global), 0); AosOut.Ln; AosOut.String("SYSTEM.ADR(global[0])= "); AosOut.Int(SYSTEM.ADR(global[0]), 0); AosOut.Ln; AosOut.String("SYSTEM.ADR(local)= "); AosOut.Int(SYSTEM.ADR(local), 0); AosOut.Ln; AosOut.String("SYSTEM.ADR(local[0])= "); AosOut.Int(SYSTEM.ADR(local[0]), 0); AosOut.Ln; RETURN NIL END Test; END AddressTest.Test ~ S.Free AddressTest ~ SYSTEM.ADR(heap)= -2059403332 SYSTEM.ADR(heap[0])= 73838632 SYSTEM.ADR(global)= 73837480 SYSTEM.ADR(global[0])= 73837480 SYSTEM.ADR(local)= -2059403328 SYSTEM.ADR(local[0])= -2059403328 Bernhard
Thanks, ... Peter
Peter, I suggested using SYSTEM.ADR(source[0]) instead of SYSTEM.ADR(source) because I do not know if a comparison with the latter will give the expectet result for your example. SYSTEM.ADR(source[0]) explicitely retrieves the address of the first character in the array while SYSTEM.ADR(source) (I think) it will return the address of the variable source, and not the address *inside* the variable source. Maybe SYSTEM.ADR(source) will work for you, but SYSTEM.ADR(source[0]) will work for sure. Lior ----- Original Message ----- From: <shark@gulfnet.sd64.bc.ca> To: <oberon@lists.inf.ethz.ch> Sent: Thursday, September 15, 2005 7:28 PM Subject: Re (2): [Oberon] identity of two VARs
David,
d> .... SYSTEM.ADR(source) ... will necessarily differ from SYSTEM.ADR(target), since the two locations are disjoint.
I was allowing the possibility that a client invokes Identical(astring, astring).
I'm missing a subtlety. source[0] is where source begins and target[0] is where target begins. So how can (SYSTEM.ADR(source[0]) = SYSTEM.ADR(target[0])) differ from (SYSTEM.ADR(source) = SYSTEM.ADR(target))?
Perhaps an example?
Thanks, ... Peter
Desktops.OpenDoc http://carnot.pathology.ubc.ca/
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://www.mail.inf.ethz.ch/lists/listinfo/oberon
participants (3)
-
Bernhard Egger -
Lior Wehrli -
shark@gulfnet.sd64.bc.ca