Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding "monitors"

141 views
Skip to first unread message

Ron Aaron

unread,
Jul 25, 2017, 2:34:37 AM7/25/17
to
In the next release of 8th I'm adding monitors. They're implemented in
the dev-version right now.

https://8th-dev.com/forum/index.php/topic,1292.msg6942.html

The idea is that you can monitor a variable and be informed when it
changes value.

My implementation works for the 8th types "var", "array", and "map". The
implementation uses an array of words which are invoked if the
underlying container is modified.

So e.g.

: monitor @ . cr ;
var x
x ' monitor +monitor
123 somevar !

would print "123", since the monitor word gets invoked with the var on TOS.

If the container is an array, then the array as well as the affected
index are passed to the monitor. If it's a map, the map and the key are
passed in.

The purpose I had in adding this was to make it easy for a GUI
application to update or modify itself based on some dynamic
information. Haven't actually done anything with it, yet.

minf...@arcor.de

unread,
Jul 25, 2017, 4:43:41 AM7/25/17
to
In DOS times there was a hex dump monitor. I used it a lot back then...

Ron Aaron

unread,
Jul 25, 2017, 4:52:46 AM7/25/17
to


On 25/07/2017 11:43, minf...@arcor.de wrote:
> Am Dienstag, 25. Juli 2017 08:34:37 UTC+2 schrieb Ron Aaron:

> In DOS times there was a hex dump monitor. I used it a lot back then...

Yes, you could use the "dump" word for that :)

Anton Ertl

unread,
Jul 25, 2017, 5:49:23 AM7/25/17
to
Ron Aaron <ramb...@gmail.com> writes:
>In the next release of 8th I'm adding monitors.

When I read "monitor" in connection with a programming language, I
think of <https://en.wikipedia.org/wiki/Monitor_%28synchronization%29>.

>The idea is that you can monitor a variable and be informed when it
>changes value.

That's known to me as a "watchpoint".

Maybe you want to adjust your terminology to be more aligned with
common usage before release.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2017: http://euro.theforth.net/

Ron Aaron

unread,
Jul 25, 2017, 6:03:03 AM7/25/17
to


On 07/25/17 12:44, Anton Ertl wrote:
> Ron Aaron <ramb...@gmail.com> writes:
>> In the next release of 8th I'm adding monitors.
>
> When I read "monitor" in connection with a programming language, I
> think of <https://en.wikipedia.org/wiki/Monitor_%28synchronization%29>.

Hmmm.

> That's known to me as a "watchpoint".
>
> Maybe you want to adjust your terminology to be more aligned with
> common usage before release.

Perhaps "listener" is less ambiguous, and also conforms with how JUCE
uses the term. (8th uses JUCE for GUI stuff and a few other things)

Cecil Bayona

unread,
Jul 25, 2017, 10:43:41 AM7/25/17
to
I would have thought the purpose is for debugging programs as that is
the general use of a watch variable.

--
Cecil - k5nwa

Ron Aaron

unread,
Jul 25, 2017, 12:03:44 PM7/25/17
to
Well, it's not a watch variable. It's a notification hook so you can
tell when a variable has been modified, and take some action.

You could, of course, use it for debugging as well.

My purpose was to be able to, say, have a meter change when a certain
variable changed. There are obviously many ways to accomplish that, and
this is one.

Cecil Bayona

unread,
Jul 25, 2017, 12:17:32 PM7/25/17
to
Thanks for the explanation, that is better than a watch variable and
possibly quite useful in all sorts of applications, in control
applications, in multi-task environments and other situations.

--
Cecil - k5nwa

Ron Aaron

unread,
Jul 25, 2017, 12:19:58 PM7/25/17
to


On 25/07/2017 19:17, Cecil Bayona wrote:

> Thanks for the explanation, that is better than a watch variable and
> possibly quite useful in all sorts of applications, in control
> applications, in multi-task environments and other situations.

That's what I thought :)

jkn...@nicorp.f9.co.uk

unread,
Jul 25, 2017, 5:39:37 PM7/25/17
to
The Design Patterns people call something like this an Observer/Observable
pattern, or perhaps a Publish/Subscribe mechanism.

To me, a Watchpoint is something different, used at Debug time only.

J^n

Rob Sciuk

unread,
Aug 14, 2017, 2:00:58 PM8/14/17
to
On Tue, 25 Jul 2017, Ron Aaron wrote:

> Date: Tue, 25 Jul 2017 09:34:11 +0300
> From: Ron Aaron <ramb...@gmail.com>
> Newsgroups: comp.lang.forth
> Subject: Adding "monitors"
My first thought too was debug/trace. If you allow arbitrary actions,
perhaps one action might be to kick out of the program into a debug mode
monitor to allow stepping, or stack traces to occur. Allowing arbitrary
action at the variable change point can be a very useful tool ...
0 new messages