Something is missing in Component Pascal

From: [at]} <Wojtek>
Date: Thu, 3 Jul 2003 02:41:17 -0400 (EDT)

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

Hello:

  I have been strugling with BlackBox during the last few days,
and I have come to the conclusion that something is missing in
Component Pascal. Really. Perhaps I am missing something in the
language manual, in which case I apologise.

This something is well known in C as an address operator, which
we also need in a type-safe version. I searched the language report
for the word "address" and it is not there. I propose the following.

Imagine there is a function which only takes pointers. Imagine
the name of the function is Join. (Now you can feel the blues,
do not you?) Imagine that for some reason I am working with
statically declared records. This has been possible for the last
50 years, and it should still be possible with CP. So OK, let's
assume I have this fancy. So I declare the bunch of records,
and now I want to write these to a file. This also used to be
possible for the last 50 years. So I am writing to a file using
Stores.Writer and I am getting what? You bet. TRAP 21. Everybody
still with me?

OK, so I start reading Stores documentation and I find the following
remedy which is supposed to help with TRAP 21.

IF ~Stores.Joined(s1, s2) THEN
   IF ~Stores.Unattached(s2) THEN
       s2 := Stores.CopyOf(s2)
   END;
   Stores.Join(s1, s2)
END;

Wonderful. So I start using it and I get what? You bet. Compilation
error. My stores are records, not pointers.

So now I have a question. How do I call the function Join which expects
a pointer, if I have a statically declared record, either global variable
or a stack variable?

In case this is trivial, I will really appreciate your telling me.
We have an experiment next week and I do need this software to work
without TRAP 21.

In case there is no trivial solution, I will temporarily dump BB and start
using C++ for the time being, where such stupid traps do not happen.
I would also propose the following syntax to be added to the language:

(*declaration*)
VAR r1, r2: RECORD (Stores.Store) (*some data*) END;
    s: Stores.Store;

BEGIN
IF ~Stores.Joined(POINTER TO r1, POINTER TO r2) THEN
   IF ~Stores.Unattached (POINTER TO r2) THEN
       s := Stores.CopyOf (POINTER TO r2)
   END;
   Stores.Join(POINTER TO r1, s)
END;

You feel the blues? The "POINTER TO r" is the opposite to dereferencing,
that is the "address of" operator. It should be possible anywhere where
the opposite could be used, that is

VAR p: POINTER TO r;

BEGIN NEW(p); (* now we can use p^ *)

If I can use p^ to fill it with data, and p to pass to a function,
then it should be possible to use r to fill with data, and "POINTER TO r"
to be passed to functions.

In case you do not like my syntax, let it be ^r as the opposite to p^,
or &r if you like C style, or POINTER(r), or whatever. I do not care.
All that I want is to be able to use the framework, where functions
are defined with pointers, and they do not want to be called with records.

In case I am missing something obvious, I stand corrected and I apologize.

I wish everybody a good 4-th July.

Wojtek Skulski skulski{([at]})nowhere.xy


PS1: I hope the proposed solution will not be as follows, but I will use
     this if nothing else helps, because we have the experiment next week.

            SYSTEM.VAL(ptrType, SYSTEM.ADR(record))


PS2: Gerard, I do not think you are there yet. The traps happen when I am
     dealing with histograms which are pointed to from the tree nodes.
     Once I display such a histogram, it gets joined to some viev, and
     thus its domain gets dirty. Now I cannot store these dirty histos
     anymore. This problem is hidden deep in the dungeons of BlackBox.
     You do not see it yet unless you have some pointers to stores
     attached to your trees. The tree itself does not have this problem.
     The Dialog tree is not a store anyway. The collection of stores
     develops the collective problem when some stores get their domains
     attached to something else than other stores. So it is all pretty
     nonobvious.



--------------------------------------------

To unsubscribe from this mailing list, send a message containing the word "unsubscribe" to:
   blackbox-request{([at]})nowhere.xy

To get a list of valid e-mail commands and instructions on their usage, send a message containing the word "help" to the above address.

Send any problem reports or questions related to this email list to the list owner at
   owner-blackbox{([at]})nowhere.xy

Current posting policy:

a) To post you should use the same address by which you are subscribed to the mailing list. That way, the list server will recognize you as subscriber and forward your posting immediately, without creating any overhead.

b) If, for some reason, you cannot post from the address, by which you are subscribed, your message will be moderated to avoid spam. Please understand that moderation will often cause some delay, in particular over weekends or holydays.


----boundary-LibPST-iamunique-666486847_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7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b2lkIHNwYW0uIFBs
ZWFzZSB1bmRlcnN0YW5kIHRoYXQgbW9kZXJhdGlvbiB3aWxsIG9mdGVuIGNhdXNlIHNvbWUgZGVs
YXksIGluIHBhcnRpY3VsYXIgb3ZlciB3ZWVrZW5kcyBvciBob2x5ZGF5cy5ccGFyDQp9


----boundary-LibPST-iamunique-666486847_-_---
Received on Thu Jul 03 2003 - 08:41:17 UTC

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