Re: Records that could be arrays



On 25 Feb 2006 19:24:32 -0800, Steve Whalen wrote:

Dmitry A. Kazakov wrote:
... The rest is a question of language deficiency. In this case an
inability to provide an array interface to a record type (to have
enumerated components), or a record interface to an array (to have named
components.) ...

I'm not sure what you mean by a language deficiency. If you really
want to address an object as either a record or an array, doesn't
something like this meet your needs?

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Redefine is

type IntRecord is
record
FirstInt : Integer;
SecondInt : Integer;
end record;
type IntArray is
array (1 .. 2) of Integer;

RecVar : IntRecord := (FirstInt => 1, SecondInt => 2);

ArrayVar : IntArray;
for ArrayVar'Address
use RecVar'Address;

(:-)) Is it C or FORTRAN? I thought nobody uses EQUIVALENCE blocks anymore!

No, the above is not an implementation of two interfaces by the same type.
It is two overlapped objects of two different types. The difference, apart
from safety issues, is that you have to do it on per instance basis. To get
it right, you need 1) multiple interface inheritance (this comes with Ada
200Y) 2) abstract array and record interfaces (this does not.)

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: passing a NULL pointer from vb6 to an ATL method
    ... COBJINTERFACES and use the C macro for calling into the interface. ... local/call_as is necessary fior marshaling. ... Dim array as Double ... Then you need to write two shim functions in C to link with the ...
    (microsoft.public.vc.atl)
  • Re: Anders Hejlsberg comment on immutable objects
    ... > example of a situation where a read interface does help out. ... > able to read the byte array, ... > and trust the server method, you simply pass the full blown object. ... what is a violation of a const contract. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: .NET and COM Interop
    ... > I added a function that sets the array and it worked, ... To implement the interface properly you have to be a bit sneaky. ... try to implement the property properly, the compiler will complain. ... AssemblyInfo file whereas C# does not. ...
    (microsoft.public.dotnet.framework.interop)
  • ptrace API extensions for BTS
    ... I would like to discuss the ptrace user interface for the BTS extension. ... we need to provide access to an array of BTS records ...
    (Linux-Kernel)
  • Re: Can this be automation compatible?
    ... the interface is probably marshaled ... and it cannot be the Automation interface of an ActiveX ... > according to his question it's part of a dual interface. ... > Chapters Pointer to an array of chapters per title. ...
    (microsoft.public.win32.programmer.ole)