Re: [BLACKBOX] Exporting records / record fields question

From: [at]} <Alexander>
Date: Wed, 28 Jul 2010 20:12:36 +0700

----boundary-LibPST-iamunique-1835056917_-_-
Content-type: text/plain

Hello!

> My questions are:
>
> 1. Can you think of any real-world scenarios where this would be useful? If
> so what should the 'interface' show?

  The real-world scenario for this is when you don't want to publish
the record type so that client modules can't make extensions. If you
don't publish the name nobody else can use it as a basic type.
  The interface definition is correct as it is.

> 2. Can you think of any problems / side-effects associated with being able
> to do this?

  The result is also that nobody can create instances of the
unpublished type, so inside the module you can be sure that all the
routines are fed with a correctly initialized entities, because they
originate from the module itself. I think it's a very clever way to
forbid extensions (or to control the object population) without using
additional keywords (ABSTRACT, EXTENSIBLE or LIMITED, which is the
(more flexible) way it is done in Component Pascal).
  I use this feature to control extensibility in my Oberon-2 programs.
  Also, you can create enumerations with objects like week days:
TYPE
   WeekDay = POINTER TO RECORD dayNumber-: INTEGER END; (* the type is
not published *)
VAR
  monday-, tuesday-, ... : WeekDay;

PROCEDURE NextDay* (thisDay: WeekDay): WeekDay;

  Client modules can only call "NextDay" by passing it an instance of
a variable from the existing global set, but they can't create a new
day.
  Of course, then you have another routine to change which day of the
week is considered "first" - Monday or Sunday - by changing the
dayNumber variable inside the set of global objects, and you will be
absolutely certain that there is no other place in client code that
must be updated, because clients can't extend the set.

> 3. Would it be a good thing or a bad thing if a compiler reported an error
> if you tried to export a field from a record if the record type itself was
> not exported?

  I don't think it is an error of any kind, so there is no need for a
special message.

---=====---
 Alexander


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1835056917_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0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ciBhXHBhcg0Kc3BlY2lhbCBtZXNzYWdlLlxwYXINClxwYXINCi0tLT09PT09LS0tXHBhcg0K
IEFsZXhhbmRlclxwYXINClxwYXINClxwYXINCi0tLS1ccGFyDQpUbyB1bnN1YnNjcmliZSwgc2Vu
ZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBMSVNU
Uy5PQkVST04uQ0h9fQByZXF1
----boundary-LibPST-iamunique-1835056917_-_---
Received on Wed Jul 28 2010 - 15:12:36 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:30 UTC