[Oberon] FPGA - Pictures.Mod composition
Jörg
joerg.straube at iaeth.ch
Mon Oct 2 16:19:42 CEST 2017
Tomas
Good coding practice in Oberon (-2 or -07) is:
"Split creation (NEW) from initialization"
As Chris mentioned reason is described in
http://ssw.jku.at/Research/Books/Oberon2.pdf chapter 8.1
I would call the procedures not "New" and "New2" but rather "InitBitmap" and
"InitPicture" or "InitBM" and "InitPic" if you prefer shorter names :-)
br
Jörg
-----Original Message-----
From: Oberon [mailto:oberon-bounces at lists.inf.ethz.ch] On Behalf Of Tomas
Kral
Sent: Monday, October 02, 2017 12:37 PM
To: oberon at lists.inf.ethz.ch
Subject: Re: [Oberon] FPGA - Pictures.Mod composition
On Sun, 1 Oct 2017 20:23:21 +0200
August Karlstrom <fusionfile at gmail.com> wrote:
> common approach is to separate memory allocation
> and initialization
Hi,
I would know the reason for separating. As FPGA { Oberon-07, V5 } is
about building system from scratch while making it simple, we could
possibly also experiment with new tricks here. I have therefore merged
these procedures into one.
> PROCEDURE Bitmaps.New(w, h, dpt) : Bitmaps;
> PROCEDURE Bitmaps.New2(B: Bitmap; w, h, dpt) : Bitmaps;
PROCEDURE New*(B: Bitmap; w, h, dpt: INTEGER) : Bitmap;
BEGIN
IF B = NIL THEN NEW(B) END; (* create itself *)
IF B # NIL THEN (* initialise itself *)
(* ... *) (* allocate itself *)
END
RETURN B END New;
VAR b: Bitmap; p: Picture
b := Bitmaps.New(NIL, w, h, 1); (* creating bitmap *)
NEW(b); Bitmaps.New(b, w, h, 1); (* also creating bitmap *)
NEW(p); b := Bitmaps.New(p, w, h, 1); (* creating picture *)
Seems simple, does the job, bad idea?
--
Tomas Kral <thomas.kral at email.cz>
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon
More information about the Oberon
mailing list