[Oberon] FPGA - Pictures.Mod composition
August Karlstrom
fusionfile at gmail.com
Sun Oct 1 20:23:21 CEST 2017
On 2017-10-01 18:57, Tomas Kral wrote:
> Just realised when Pictures type is extended from Bitmaps,
> Bitmaps.New(P,..) needs to accept pointer to its `superclass',
> otherwise some type members are duplicated. Correct???
>
> I need to to be also explained, what we call `superclass',
> `baseclass' in Oberon terminology.
>
> Order of type extension:
> T1 -> T2 (T1) -> T3 (T2).. Tn(Tm)
>
> Order of type creation:
> M1.New(T2,..) <- M2.New(T3,..) <- .. Mn.New(Tm,..)
>
> For the reason above I use two New procedures in Bitmaps:
>
> PROCEDURE Bitmaps.New(w, h, dpt) : Bitmaps;
> PROCEDURE Bitmaps.New2(B: Bitmap; w, h, dpt) : Bitmaps;
>
> Is there a better recommended naming standard for this, than the above?
If I'm not mistaken the common approach is to separate memory allocation
and initialization like this:
Picture = POINTER TO RECORD
w, h: INTEGER
END
Bitmap = POINTER TO RECORD (Picture)
(*...*)
END
PROCEDURE InitPicture(p: Picture; w, h: INTEGER);
BEGIN
p.w := w;
p.h := h
END InitPicture
PROCEDURE InitBitmap(b: Bitmap; w, h: INTEGER);
BEGIN
InitPicture(b, w, h)
(*...*)
END InitBitmap
PROCEDURE Test;
VAR bitmap: Bitmap;
BEGIN
NEW(bitmap);
InitBitmap(bitmap, 100, 100)
END Test
-- August
More information about the Oberon
mailing list