Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #50166 > unrolled thread

the IS-A function

Started byhughaguilar96@gmail.com
First post2016-08-15 23:10 -0700
Last post2016-08-18 18:31 -0700
Articles 20 on this page of 45 — 12 participants

Back to article view | Back to comp.lang.forth


Contents

  the IS-A function hughaguilar96@gmail.com - 2016-08-15 23:10 -0700
    Re: the IS-A function hughaguilar96@gmail.com - 2016-08-16 00:22 -0700
    Re: the IS-A function hughaguilar96@gmail.com - 2016-08-16 14:01 -0700
    Re: the IS-A function hughaguilar96@gmail.com - 2016-08-16 14:20 -0700
      Re: the IS-A function JennyB <jennybrien@googlemail.com> - 2016-08-17 05:04 -0700
        Re: the IS-A function hughaguilar96@gmail.com - 2016-08-17 10:52 -0700
          Re: the IS-A function hughaguilar96@gmail.com - 2016-08-17 19:31 -0700
        Re: the IS-A function anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-18 08:00 +0000
          Re: the IS-A function JennyB <jennybrien@googlemail.com> - 2016-08-18 21:52 -0700
      Re: the IS-A function Julian Fondren <julian.fondren@gmail.com> - 2016-08-17 07:11 -0700
      Re: the IS-A function franck.bensusan@gmail.com - 2016-08-17 23:13 -0700
        Re: the IS-A function hughaguilar96@gmail.com - 2016-08-18 11:59 -0700
          Re: the IS-A function hughaguilar96@gmail.com - 2016-08-18 15:11 -0700
            Re: the IS-A function franck.bensusan@gmail.com - 2016-08-18 23:14 -0700
              Re: the IS-A function hughaguilar96@gmail.com - 2016-08-19 01:01 -0700
                Re: the IS-A function franck.bensusan@gmail.com - 2016-08-19 03:14 -0700
                  Re: the IS-A function Ron Aaron <rambamist@gmail.com> - 2016-08-19 13:31 +0300
                  Re: the IS-A function Raimond Dragomir <raimond.dragomir@gmail.com> - 2016-08-19 03:39 -0700
                    Re: the IS-A function franck.bensusan@gmail.com - 2016-08-19 06:49 -0700
                  Re: the IS-A function lawrencedo99@gmail.com - 2016-08-19 14:55 -0700
                    Re: the IS-A function Paul Rubin <no.email@nospam.invalid> - 2016-08-19 14:57 -0700
                      Re: the IS-A function franck.bensusan@gmail.com - 2016-08-20 10:29 -0700
                        Re: the IS-A function Ron Aaron <rambamist@gmail.com> - 2016-08-20 20:35 +0300
                        Re: the IS-A function Paul Rubin <no.email@nospam.invalid> - 2016-08-20 10:53 -0700
                          Re: the IS-A function Julian Fondren <julian.fondren@gmail.com> - 2016-08-20 11:01 -0700
                            Re: the IS-A function Paul Rubin <no.email@nospam.invalid> - 2016-08-20 19:36 -0700
                              Re: the IS-A function Julian Fondren <julian.fondren@gmail.com> - 2016-08-20 20:15 -0700
                        Re: the IS-A function lawrencedo99@gmail.com - 2016-08-21 14:53 -0700
                Re: the IS-A function Cecil Bayona <cbayona@cbayona.com> - 2016-08-19 08:28 -0500
                  Re: the IS-A function hughaguilar96@gmail.com - 2016-08-20 19:30 -0700
                    Re: the IS-A function Cecil Bayona <cbayona@cbayona.com> - 2016-08-20 22:20 -0500
                      Re: the IS-A function hughaguilar96@gmail.com - 2016-08-20 20:50 -0700
                        OOP (was: the IS-A function) Ron Aaron <rambamist@gmail.com> - 2016-08-21 07:21 +0300
                        Re: the IS-A function Mark Wills <markwills1970@gmail.com> - 2016-08-21 01:42 -0700
                          Re: the IS-A function Coos Haak <htrofhc@gmail.com> - 2016-08-21 14:16 +0200
                            Re: the IS-A function Mark Wills <markwills1970@gmail.com> - 2016-08-21 11:08 -0700
                              Re: the IS-A function Coos Haak <htrofhc@gmail.com> - 2016-08-21 21:25 +0200
                          Re: the IS-A function hughaguilar96@gmail.com - 2016-08-21 12:01 -0700
        Re: the IS-A function hughaguilar96@gmail.com - 2016-08-18 17:08 -0700
          Re: the IS-A function hughaguilar96@gmail.com - 2016-08-19 00:29 -0700
            Re: the IS-A function hughaguilar96@gmail.com - 2016-08-28 11:01 -0700
              Re: the IS-A function hughaguilar96@gmail.com - 2016-08-28 14:45 -0700
      Re: the IS-A function Mark Wills <markwills1970@gmail.com> - 2016-08-18 02:22 -0700
        Re: the IS-A function hughaguilar96@gmail.com - 2016-08-18 12:02 -0700
        Re: the IS-A function hughaguilar96@gmail.com - 2016-08-18 18:31 -0700

Page 2 of 3 — ← Prev page 1 [2] 3  Next page →


#50259

FromPaul Rubin <no.email@nospam.invalid>
Date2016-08-19 14:57 -0700
Message-ID<87pop4to9x.fsf@jester.gateway.pace.com>
In reply to#50258
lawrencedo99@gmail.com writes:
> I agree laptops can’t handle this, but desktops and servers can.

Yes, that's basically the point of a server.  There are some cheap
hosting companies (Hetzner etc.) building servers out of desktop
hardware.  I've had some doubts about that (non-ECC memory etc) but I've
had some and in fact have run long 24/7 computations on them.  My next
one will probably use actual server hardware though--it now costs just a
few percent more.

My laptop on the other hand used to actually start smelling bad
(adhesives inside heating up or something) if you ran something cpu
intensive for longer than a few minutes.

[toc] | [prev] | [next] | [standalone]


#50282

Fromfranck.bensusan@gmail.com
Date2016-08-20 10:29 -0700
Message-ID<062906a4-6b6b-4017-9d8b-02ca93bab295@googlegroups.com>
In reply to#50259
Le vendredi 19 août 2016 23:57:48 UTC+2, Paul Rubin a écrit :
> lawrencedo99@gmail.com writes:
> > I agree laptops can’t handle this, but desktops and servers can.
> 
> Yes, that's basically the point of a server.  There are some cheap
> hosting companies (Hetzner etc.) building servers out of desktop
> hardware.  I've had some doubts about that (non-ECC memory etc) but I've
> had some and in fact have run long 24/7 computations on them.  My next
> one will probably use actual server hardware though--it now costs just a
> few percent more.
> 
> My laptop on the other hand used to actually start smelling bad
> (adhesives inside heating up or something) if you ran something cpu
> intensive for longer than a few minutes.

I'am not sure that we have the same definition of what a server is.
Because, for me, this is not the point of a server.

My definition (well, not only mine I think) is that a server offers 
services to clients (hence it's name...).
It can offer database, files, Web HTTP, services, printing, email, ... 

Its load comes from responding to clients requests, not from stand alone 
computations (like 3D rendering or personnal computations).

I know no sysadmin that would not become worried if the load of its servers 
are above 70% or would not investiguate deeply if the load reaches 100%.
Because, this means that the server can't serve new requests anymore or with
a very long delay.

For a server, availability to new requests is the most important.
And you can't provide this if it runs at 100% CPU.

That is why I say that you will not see a server running at 100% CPU.
Let's say : a server that is doing its job of serving can't run at 100% CPU 
24/24 :)

After that, if you want to buy a server to make your computations (or 3D
rendering), of course you can, and you can go to 100% CPU load, 
no problem with that... But you don't use it as a server.

[toc] | [prev] | [next] | [standalone]


#50283

FromRon Aaron <rambamist@gmail.com>
Date2016-08-20 20:35 +0300
Message-ID<npa4ds$6gp$1@dont-email.me>
In reply to#50282

On 20/08/2016 20:29, franck.bensusan@gmail.com wrote:

> My definition (well, not only mine I think) is that a server offers 
> services to clients (hence it's name...).
> It can offer database, files, Web HTTP, services, printing, email, ... 

Precisely.  I run a mail "server" off a broken laptop.  It works
perfectly for that task.


> After that, if you want to buy a server to make your computations (or 3D
> rendering), of course you can, and you can go to 100% CPU load, 
> no problem with that... But you don't use it as a server.

Again, precisely.  One of my clients had purchased 64-core servers and
was very concerned about making sure as many cores as possible were
operating as much as possible at 100%.  That client was interested in
super-low-latency processing, not serving up services.

[toc] | [prev] | [next] | [standalone]


#50284

FromPaul Rubin <no.email@nospam.invalid>
Date2016-08-20 10:53 -0700
Message-ID<878tvrtjgq.fsf@jester.gateway.pace.com>
In reply to#50282
franck.bensusan@gmail.com writes:
> That is why I say that you will not see a server running at 100% CPU.
> Let's say : a server that is doing its job of serving can't run at 100% CPU 
> 24/24 :)

This is why load balancing was invented.

[toc] | [prev] | [next] | [standalone]


#50285

FromJulian Fondren <julian.fondren@gmail.com>
Date2016-08-20 11:01 -0700
Message-ID<a47cb6ec-e9d6-497e-91af-c9b1eda04741@googlegroups.com>
In reply to#50284
On Saturday, August 20, 2016 at 12:53:59 PM UTC-5, Paul Rubin wrote:
> franck.bensusan@gmail.com writes:
> > That is why I say that you will not see a server running at 100% CPU.
> > Let's say : a server that is doing its job of serving can't run at 100% CPU 
> > 24/24 :)
> 
> This is why load balancing was invented.

OK, now you're load balancing requests across N servers.

However, as the N servers are each running at 100% CPU "as desired",
they can receive no additional requests.  Load balancing changes
nothing.  If you're at 100% CPU, then you either 1) need additional
CPUs, or 2) need to squash a massive abuse/performance issue, or 3)
are running some kind of self-contained system where both resources
and demands on resources are entirely under your control and balanced
by you.

[toc] | [prev] | [next] | [standalone]


#50304

FromPaul Rubin <no.email@nospam.invalid>
Date2016-08-20 19:36 -0700
Message-ID<87oa4msv91.fsf@jester.gateway.pace.com>
In reply to#50285
Julian Fondren <julian.fondren@gmail.com> writes:
> However, as the N servers are each running at 100% CPU "as desired",
> they can receive no additional requests.

That's not how it works.  You can receive as many requests as you want.
They just take longer to process.  Since later requests are often
dependent on the results of earlier requests, your throughput stays the
same but you get fewer requests per minute from a given client.  There
are also scheduling priorities: you can have a long-running background
task that gives up cycles as needed to shorter requests.

I know I run my own machines at 100% on large computational tasks lots
of the time, but I can still do other stuff on the machine.  I don't
notice any difference in interactive response on most quick operations.
Bigger operations like compiles take noticably longer when the machine
is loaded but it's still not too bad.

> Load balancing changes nothing.  If you're at 100% CPU, then you
> either 1) need additional CPUs, or 2) need to squash a massive
> abuse/performance issue, 

If you have persistent overload then you do add more CPU's, such as by
calling an API to spin up additional VM's.  If it's sporadic then you
can choose to just live with it.  Think of rush hour on the freeway.

> 3) are running some kind of self-contained system where both resources
> and demands on resources are entirely under your control and balanced
> by you.

This is in fact often the situation.  Think of a video transcoding farm.

[toc] | [prev] | [next] | [standalone]


#50307

FromJulian Fondren <julian.fondren@gmail.com>
Date2016-08-20 20:15 -0700
Message-ID<781b1c85-2f25-4750-998f-a09c3d54d708@googlegroups.com>
In reply to#50304
On Saturday, August 20, 2016 at 9:37:02 PM UTC-5, Paul Rubin wrote:
> > 3) are running some kind of self-contained system where both resources
> > and demands on resources are entirely under your control and balanced
> > by you.
> 
> This is in fact often the situation.  Think of a video transcoding farm.

"In fact it's often the situation that you can see all surface borders
of large bodies of water.  Think of the water in a well."
	-- a frog in a well

"The most common use of a car is to drive it in a circle as fast as
you can."
	-- a NASCAR fan

If you're running a self-contained system like this, then what you
have is a personal supercomputer that only happens, for convenience
and efficiency of implementation, to involve networking protocols and
multiple physical servers.  My HP49G was also capable of networking.


I'll just agree that servers perform a lot better with maxed out CPU
usage than they do with other kinds of low resource conditions.  Most
servers I deal with can't even function when their filesystem activity
is forced to actually continuously hit a disk instead of filesystem
cache; low memory conditions just drive them into a coma.


-- Julian

[toc] | [prev] | [next] | [standalone]


#50361

Fromlawrencedo99@gmail.com
Date2016-08-21 14:53 -0700
Message-ID<2f5767af-6bdf-4cf7-b283-fee6e24ccc28@googlegroups.com>
In reply to#50282
On Sunday, August 21, 2016 at 5:29:09 AM UTC+12, franck....@gmail.com wrote:
> I know no sysadmin that would not become worried if the load of its servers 
> are above 70% or would not investiguate deeply if the load reaches 100%.
> Because, this means that the server can't serve new requests anymore or with
> a very long delay.

That depends on whether it needs to. There are different kinds of workloads (see queueing theory).

For example, a renderfarm or a supercomputer typically runs with batch-style workloads, where users have booked in advance and expect their jobs to be processed according to a prearranged schedule.

And then there are cloud-type services, with more ad-hoc workloads. Google runs something like half a million servers, and when you enter a query, you typically get a response within milliseconds.

The short term for all this is “QoS” (“Quality of Service”). Some workloads need high throughput, others need low latency. And if you need both? Well, then you pay more.

[toc] | [prev] | [next] | [standalone]


#50247

FromCecil Bayona <cbayona@cbayona.com>
Date2016-08-19 08:28 -0500
Message-ID<np71io$vq2$1@dont-email.me>
In reply to#50238

On 8/19/2016 3:01 AM, hughaguilar96@gmail.com wrote:

> I don't foresee providing Straight Forth with support for multi-core systems --- that is too difficult (a bit more sophisticated than a blue-collar guy like me wants to delve into), and it puts a straight-jacket on the programs (making data immutable so one process doesn't clobber another process).
> 1.) Multi-core support is not necessary for the primary purpose of Straight Forth (cross-compilers), and I don't want to add extra complexity that will get in the way of my primary purpose for no benefit.
> 2.) Multi-core support is not necessary for the secondary purpose of Straight Forth (numeric and text processing) because performance isn't all that crucial. The only program I have in mind is CAM (generating gcode for CNC machines), and this is not time-critical. Even if Oforth given a dual-core system is twice the speed of Straight Forth, nobody will care --- the difference is 1 minute compared to 2 minutes to generate a gcode program --- ease of development of the CAM script is much more important.
>
> What do you use Oforth for that is so speed-critical that your multi-core support is necessary?
>
Multi-threading which is what really going on is quite useful in many 
applications that need to carry on more than one task smoothly, web 
applications has been mentioned but in many others it can be useful.

In NC applications for example you want to keep the machine position, or 
be moving along a path, while preparing the next move, while also 
monitoring the keyboard for operator actions, and while communicating 
with a PC or another  machine to download the next program to run, 
multi-threading allows all those processes to run simultaneously and 
smoothly. As far as other cores the OS takes care of that, you ask to 
run another thread and the OS decides to use another core or not based 
on software load, your software need not be concerned the OS takes care 
of where the thread runs.

Cooperative multitasking can in many simple cases be used but sometimes 
that doesn't work well, in NC example the thread that keeps the position 
or makes a move, must be executed on schedule by an accurate timer to 
keep the system stable so co-operative multitasking will not work for 
that task, an interrupt driven task is necessary.

Personally not having multi-threading will limit the applications one 
can write that will run well and run smoothly, its another vital tool in 
a modern programming task just as libraries, and other items are.
-- 
Cecil - k5nwa

[toc] | [prev] | [next] | [standalone]


#50303

Fromhughaguilar96@gmail.com
Date2016-08-20 19:30 -0700
Message-ID<32679b32-42ac-4673-a118-f08cb03c3dec@googlegroups.com>
In reply to#50247
On Friday, August 19, 2016 at 6:28:58 AM UTC-7, Cecil - k5nwa wrote:
> On 8/19/2016 3:01 AM, hughaguilar96@gmail.com wrote:
> 
> > I don't foresee providing Straight Forth with support for multi-core systems --- that is too difficult (a bit more sophisticated than a blue-collar guy like me wants to delve into), and it puts a straight-jacket on the programs (making data immutable so one process doesn't clobber another process).
> > 1.) Multi-core support is not necessary for the primary purpose of Straight Forth (cross-compilers), and I don't want to add extra complexity that will get in the way of my primary purpose for no benefit.
> > 2.) Multi-core support is not necessary for the secondary purpose of Straight Forth (numeric and text processing) because performance isn't all that crucial. The only program I have in mind is CAM (generating gcode for CNC machines), and this is not time-critical. Even if Oforth given a dual-core system is twice the speed of Straight Forth, nobody will care --- the difference is 1 minute compared to 2 minutes to generate a gcode program --- ease of development of the CAM script is much more important.
> >
> > What do you use Oforth for that is so speed-critical that your multi-core support is necessary?
> >
> Multi-threading which is what really going on is quite useful in many 
> applications that need to carry on more than one task smoothly, web 
> applications has been mentioned but in many others it can be useful.
> 
> In NC applications for example you want to keep the machine position, or 
> be moving along a path, while preparing the next move, while also 
> monitoring the keyboard for operator actions, and while communicating 
> with a PC or another  machine to download the next program to run, 
> multi-threading allows all those processes to run simultaneously and 
> smoothly. As far as other cores the OS takes care of that, you ask to 
> run another thread and the OS decides to use another core or not based 
> on software load, your software need not be concerned the OS takes care 
> of where the thread runs.
> 
> Cooperative multitasking can in many simple cases be used but sometimes 
> that doesn't work well, in NC example the thread that keeps the position 
> or makes a move, must be executed on schedule by an accurate timer to 
> keep the system stable so co-operative multitasking will not work for 
> that task, an interrupt driven task is necessary.
> 
> Personally not having multi-threading will limit the applications one 
> can write that will run well and run smoothly, its another vital tool in 
> a modern programming task just as libraries, and other items are.
> -- 
> Cecil - k5nwa

When I said that Straight Forth would be used for CAM, I meant that you would have Forth programs running on the desktop computer that generated gcode programs for CNC machines. This is not real-time. You just generate the gcode programs and upload them into the CNC machine at your convenience. My SLIDE-RULE.4TH program is an example of CAM because it generates a gcode program for a CNC milling machine (the milling machine would use a scribe to etch the pattern onto the surface of color-anodized aluminum).

The CNC machine is hard real-time. The MiniForth at Testra was used for both motion-control boards used in both milling machines and laser-etchers. The laser etcher had to run fast and at a consistent speed (if it slows down when changing directions, you get a burned splotch at the corner). All of this was interrupt driven; there was no OS. The board was a dual-processor system. There was an 8032 with 64MB of RAM that would communicate with the desktop-computer --- it could hold several large files in its RAM --- it fed the information from the current file into the MiniForth as needed (the MiniForth didn't have enough RAM to hold an entire file). The MiniForth also lacked a UART, so it couldn't communicate with the desktop computer via RS-232 --- it could only communicate with the 8032 via parallel ports.

Anyway --- Straight Forth is for desktop computers. It can use the OS multi-tasking services for loosely-coupled parallelism, pretty much the same as C or C++ programs --- I don't plan on supporting multi-core systems though, as done in Oforth, because that is too complicated for me and is not needed for anything that I plan on using Straight Forth for.

Primarily, the purpose of Straight Forth is to support cross-compilation of Forth programs --- those Forth programs would run on micro-controllers and may very well be hard-real-time --- Straight Forth will have features such as LITERAL being vectored that are needed for cross-compiling but which are banned in ANS-Forth or Forth-200x.

[toc] | [prev] | [next] | [standalone]


#50308

FromCecil Bayona <cbayona@cbayona.com>
Date2016-08-20 22:20 -0500
Message-ID<npb6l8$a3l$1@dont-email.me>
In reply to#50303

On 8/20/2016 9:30 PM, hughaguilar96@gmail.com wrote:
> On Friday, August 19, 2016 at 6:28:58 AM UTC-7, Cecil - k5nwa wrote:
>> On 8/19/2016 3:01 AM, hughaguilar96@gmail.com wrote:
>>
>>> I don't foresee providing Straight Forth with support for multi-core systems --- that is too difficult (a bit more sophisticated than a blue-collar guy like me wants to delve into), and it puts a straight-jacket on the programs (making data immutable so one process doesn't clobber another process).
>>> 1.) Multi-core support is not necessary for the primary purpose of Straight Forth (cross-compilers), and I don't want to add extra complexity that will get in the way of my primary purpose for no benefit.
>>> 2.) Multi-core support is not necessary for the secondary purpose of Straight Forth (numeric and text processing) because performance isn't all that crucial. The only program I have in mind is CAM (generating gcode for CNC machines), and this is not time-critical. Even if Oforth given a dual-core system is twice the speed of Straight Forth, nobody will care --- the difference is 1 minute compared to 2 minutes to generate a gcode program --- ease of development of the CAM script is much more important.
>>>
>>> What do you use Oforth for that is so speed-critical that your multi-core support is necessary?
>>>
>> Multi-threading which is what really going on is quite useful in many
>> applications that need to carry on more than one task smoothly, web
>> applications has been mentioned but in many others it can be useful.
>>
>> In NC applications for example you want to keep the machine position, or
>> be moving along a path, while preparing the next move, while also
>> monitoring the keyboard for operator actions, and while communicating
>> with a PC or another  machine to download the next program to run,
>> multi-threading allows all those processes to run simultaneously and
>> smoothly. As far as other cores the OS takes care of that, you ask to
>> run another thread and the OS decides to use another core or not based
>> on software load, your software need not be concerned the OS takes care
>> of where the thread runs.
>>
>> Cooperative multitasking can in many simple cases be used but sometimes
>> that doesn't work well, in NC example the thread that keeps the position
>> or makes a move, must be executed on schedule by an accurate timer to
>> keep the system stable so co-operative multitasking will not work for
>> that task, an interrupt driven task is necessary.
>>
>> Personally not having multi-threading will limit the applications one
>> can write that will run well and run smoothly, its another vital tool in
>> a modern programming task just as libraries, and other items are.
>> --
>> Cecil - k5nwa
>
> When I said that Straight Forth would be used for CAM, I meant that you would have Forth programs running on the desktop computer that generated gcode programs for CNC machines. This is not real-time. You just generate the gcode programs and upload them into the CNC machine at your convenience. My SLIDE-RULE.4TH program is an example of CAM because it generates a gcode program for a CNC milling machine (the milling machine would use a scribe to etch the pattern onto the surface of color-anodized aluminum).
>
> The CNC machine is hard real-time. The MiniForth at Testra was used for both motion-control boards used in both milling machines and laser-etchers. The laser etcher had to run fast and at a consistent speed (if it slows down when changing directions, you get a burned splotch at the corner). All of this was interrupt driven; there was no OS. The board was a dual-processor system. There was an 8032 with 64MB of RAM that would communicate with the desktop-computer --- it could hold several large files in its RAM --- it fed the information from the current file into the MiniForth as needed (the MiniForth didn't have enough RAM to hold an entire file). The MiniForth also lacked a UART, so it couldn't communicate with the desktop computer via RS-232 --- it could only communicate with the 8032 via parallel ports.
>
> Anyway --- Straight Forth is for desktop computers. It can use the OS multi-tasking services for loosely-coupled parallelism, pretty much the same as C or C++ programs --- I don't plan on supporting multi-core systems though, as done in Oforth, because that is too complicated for me and is not needed for anything that I plan on using Straight Forth for.
>
> Primarily, the purpose of Straight Forth is to support cross-compilation of Forth programs --- those Forth programs would run on micro-controllers and may very well be hard-real-time --- Straight Forth will have features such as LITERAL being vectored that are needed for cross-compiling but which are banned in ANS-Forth or Forth-200x.
>
I know the difference, and you know the difference, however I was 
responding to comments about StraightForth which is a desktop program so 
there is a OS under everything that can handle multiple CPUs, all one 
needs to do is fire off threads and the OS takes care of multiple cores 
if they exist or not.

Curious, any sort of schedule when your Forth will be ready? I figure it 
won't be for a while.

I have thought about it and for new projects I will restrict myself to 
using VFX  Professional ARM Compiler for ARM CPUs, and for FPGA CPUs I 
will use weForth which is eForth for Windows, it's cross 
compiler/assembler is easy to modify.

For desktop uses the jury is still out. The tree contenders are VFX for 
Windows, 8th, and OForth, I have two fairly complex test program figured 
out and will attempt to use all three to see how they work out, in ease 
of programming, and speed of final results with easy of programming 
being the most important so later in the week I will ask you for your 
updated libraries to use with VFX.

-- 
Cecil - k5nwa

[toc] | [prev] | [next] | [standalone]


#50310

Fromhughaguilar96@gmail.com
Date2016-08-20 20:50 -0700
Message-ID<d62d2989-aa52-47c7-b1a3-cd121b7c347a@googlegroups.com>
In reply to#50308
On Saturday, August 20, 2016 at 8:20:12 PM UTC-7, Cecil - k5nwa wrote:
> Curious, any sort of schedule when your Forth will be ready? I figure it 
> won't be for a while.

It is not likely to be ready for a while. I'm still doing a lot of thinking in regard to the design --- I have a lot to learn about modern programming-language design, so I'm studying other languages --- there is no hurry because nobody else is making any effort at all (Forth-200x is guaranteed to be a total failure just like ANS-Forth was in 1994, so I don't worry about that becoming any kind of Standard anywhere other than Forth Inc. and MPE).

Earlier in this thread I toyed with the idea of making Straight Forth have a 1-bit tag similar to what Franck described for Oforth. I'm not actually going to do that --- I'm going to stick with a traditional Forth design (hence the name: "Straight Forth") --- I will have a simple OOP system (most likely this code that I provided in this thread).

A lot of code that I write in ANS-Forth is actually intended to become part of Straight Forth. This OOP system in this thread is an example. The STRING-STACK.4TH package is another example. Realistically, nobody will ever use any of this under ANS-Forth because it is not approved by the committee, and it contradicts Elizabeth Rather's "Forth Way" in which all new programs are written by cut-and-paste-and-modify of old programs.

> I have thought about it and for new projects I will restrict myself to 
> using VFX  Professional ARM Compiler for ARM CPUs, and for FPGA CPUs I 
> will use weForth which is eForth for Windows, it's cross 
> compiler/assembler is easy to modify.

You mentioned earlier that you were going to send me a copy of that weForth system. You said you had some non-computer issues that you were dealing with and that you would do this later when you had more free time. I'm still interested in looking at it.

> For desktop uses the jury is still out. The tree contenders are VFX for 
> Windows, 8th, and OForth, I have two fairly complex test program figured 
> out and will attempt to use all three to see how they work out, in ease 
> of programming, and speed of final results with easy of programming 
> being the most important so later in the week I will ask you for your 
> updated libraries to use with VFX.

Well, 8th and Oforth are both dynamic-OOP (they have a tag field at the top of every datum). VFX is a lot closer to what I'm going for in Straight Forth.

VFX, for example, has a way to smudge words (similar to what Forth-83 had) --- this has been removed from ANS-Forth --- that is the kind of thing I will have in Straight Forth.

I have said many times that it is important, given an xt, to be able to determine (and change) its attributes:
1.) what word-list it is in
2.) immediate or non-immediate
3.) smudged or not
4.) smudge-ready or not

Actually, I can't think of any case in which you would want to change whether a word is immediate or non-immediate --- but it is very useful to find out what it already is --- #1 #3 and #4 are all necessary for both finding out and changing.

[toc] | [prev] | [next] | [standalone]


#50311 — OOP (was: the IS-A function)

FromRon Aaron <rambamist@gmail.com>
Date2016-08-21 07:21 +0300
SubjectOOP (was: the IS-A function)
Message-ID<npba88$hg8$1@dont-email.me>
In reply to#50310
What about OOP?

On 21/08/2016 06:50, hughaguilar96@gmail.com wrote:

> Well, 8th and Oforth are both dynamic-OOP (they have a tag field at
> the top of every datum).

No, 8th is not 'dynamic-OOP'.  It's not "OOP" of any kind, in fact.  Nor
does it have a 'tag field' - but that's OK, you like to talk out of your
hat.  But "facts are stubborn things".

To clarify (for anyone interested, that is): 8th has many data types.
It knows how to discern between them, and provides an easy method for
the user to do so using ">kind".  In this it is decidedly non-ANS.

It is NOT an OOP system.  There is NO inheritance, NO data
bundling/encapsulation.  None of the usual OOP stuff.

However, it sometimes SEEMS like it has OOP-like features.  For example,
you might type at the console:

   1 2 + .

or

   "cat" " and dog" + .

and in the first case, '3' would be displayed, while in the second, "cat
and dog" would be displayed.  So you might be forgiven for thinking
there is something akin to "operator overloading".  There is not.

What is actually happening is that the "kind" of item on TOS is checked,
and the word invoked ("+" in this case) is sought in the namespace
corresponding to the TOS item's kind.  In our example, the first "+"
finds "n:+" and the
second finds "s:+".

This mechanism works well enough for simple cases, but it works much
less well for cases such as:

   [1,2,3]  ' dosomething each

In this case, the item on TOS is a word, but there is no 'each' in the
'w:' namespace.  So 8th looks for 'each' in the 'G:', or 'global'
namespace, only to fail and complain bitterly of its failure:

  "Exception: can't find: each: ..."

So to rectify this situation, we force the user to invoke the "fully
qualified name" of the word from the 'array' namespace:

   [1,2,3]  ' dosomething a:each

This works (provided 'dosomething' works, that is), and it also makes it
easier to debug.

Nevertheless, NO ACTUAL OOP is going on here.

While you can create a new data type, you cannot create one which
"inherits" from a number (for instance).  Instead, every user-created
data type contains a map (e.g. hash-table, dictionary, etc) which can be
used to store data specific to a particular instance of that data type.
Additionally, by creating a word __init__ in the new type's namespace,
one can ensure specific 'fields' are initialized (and likewise by
creating __deinit__ one can clean-up if necessary).  These fields are
simply data items contained by the user-data-item.

Hope this helps.

[toc] | [prev] | [next] | [standalone]


#50321

FromMark Wills <markwills1970@gmail.com>
Date2016-08-21 01:42 -0700
Message-ID<0a16cf88-21b8-43f1-a7be-b80f48292ed8@googlegroups.com>
In reply to#50310
The only scenario I have come across where one wants/needs to change the immediacy of a word is during the execution of IS when setting a DEFERred word. When DEFER creates a word it doesn't know if the subsequent word that it will be associated with it is going to be immediate or not. Thusly IS needs to check and act accordingly.

[toc] | [prev] | [next] | [standalone]


#50328

FromCoos Haak <htrofhc@gmail.com>
Date2016-08-21 14:16 +0200
Message-ID<15joriuw46ozy$.7ct6tmsl2rzf.dlg@40tude.net>
In reply to#50321
Op Sun, 21 Aug 2016 01:42:52 -0700 (PDT) schreef Mark Wills:

> The only scenario I have come across where one wants/needs to change
> the immediacy of a word is during the execution of IS when setting a
> DEFERred word. When DEFER creates a word it doesn't know if the
> subsequent word that it will be associated with it is going to be
> immediate or not. Thusly IS needs to check and act accordingly.

I don't understand this reasoning.

defer rund	immediate
defer ezel

' stom is rund
' stom is ezel

What must IS know about the immediacy or not of rund of ezel?

groet Coos

[toc] | [prev] | [next] | [standalone]


#50335

FromMark Wills <markwills1970@gmail.com>
Date2016-08-21 11:08 -0700
Message-ID<6bd4cf05-7165-4f5b-aaaf-abd93a6a4df2@googlegroups.com>
In reply to#50328
Defer string
' s" is string 

[toc] | [prev] | [next] | [standalone]


#50348

FromCoos Haak <htrofhc@gmail.com>
Date2016-08-21 21:25 +0200
Message-ID<1gcynd9uvyixj$.np8xbb0vdt.dlg@40tude.net>
In reply to#50335
Op Sun, 21 Aug 2016 11:08:56 -0700 (PDT) schreef Mark Wills:

> Defer string
> ' s" is string

It's not the fault of DEFER that it does not know
that S" is immediate. You had better written
  Defer string immediate

groet Coos

[toc] | [prev] | [next] | [standalone]


#50342

Fromhughaguilar96@gmail.com
Date2016-08-21 12:01 -0700
Message-ID<416183b5-de46-43b1-bc95-693ea987b956@googlegroups.com>
In reply to#50321
On Sunday, August 21, 2016 at 1:42:54 AM UTC-7, Mark Wills wrote:
> The only scenario I have come across where one wants/needs to change the immediacy of a word is during the execution of IS when setting a DEFERred word. When DEFER creates a word it doesn't know if the subsequent word that it will be associated with it is going to be immediate or not. Thusly IS needs to check and act accordingly.

Mark is making a good point here.

As a practical matter though, the user generally knows how the deferred word will be used (knows if it is immediate or not) and will know if he should manually do an IMMEDIATE or not.

Also, essentially all deferred words are non-immediate. A typical example is in my LowDraw.4th program in which I deferred the function that did the drawing of cards so I could test various drawing strategies without having to recompile the program. The only case that I can think of in which you would want to defer an immediate word would be in a cross-compiler --- specifically, LITERAL needs to be deferred --- a cross-compiler is the only app that I know of that executes at compile-time.

BTW: as fascinating as all of this is, it has nothing to do with my OOP code with its IS-A and IS-CHILD-OF and IS-PARENT-OF code --- any thread on comp.lang.forth that provides code will inevitably get hijacked --- other than Jenny, nobody has commented on my code, and she got it wrong (thought that objects were compiled with CREATE DOES>).

[toc] | [prev] | [next] | [standalone]


#50227

Fromhughaguilar96@gmail.com
Date2016-08-18 17:08 -0700
Message-ID<13a1cc3f-e9d6-46f8-8275-22cc5e406e53@googlegroups.com>
In reply to#50199
On Wednesday, August 17, 2016 at 11:13:30 PM UTC-7, franck....@gmail.com wrote:
> btw, what you call is-a is generally called IS-KINDOF (isKindOf in Oforth).
> 
> is-a generally checks only if the object's class is the same but
> does not check its parent classes.

Here is an updated version that changes IS-A to mean exactly that class, but now provides IS-KIND-OF to mean that class or any of its parents.


98769876 constant class-id  \ used to make sure a class is actually a class; must be a distinctive value

0
    w field .class-parent   \ pointer to parent class       \ must be first field
    w field .class-size     \ size of object
    w field .class-id       \ should always be CLASS-ID
constant class-struct

\ Every object has a W field in front which is a pointer to the class-struct for its class.

: check-class ( class -- )
    .class-id @  class-id <> abort" *** tried to use a class that wasn't actually a class ***" ;

: create-nada ( -- )        \ create a class that has no parent
    create
        nil ,                       \ .class-parent     \ there is no parent
        w ,                         \ .class-size       \ room for the object's pointer to its class-struct
        class-id ,                  \ .class-id         \ this is for error-checking
    does> ( -- )        
        true abort" *** it is illegal to make objects of class NADA ***" ;
        
create-nada nada            \ NADA is the only class that has no parent

\ NADA is only available so it can be the parent of classes that have no parent.
\ It is not really a class that can be used as such.

' alloc             constant heap-new           \ give this to the class to get a new object in the heap
' concrete-alloc    constant dict-new           \ give this to the class to get a new object in the dictionary

: class-size ( class -- size )    
    .class-size @
    dup 0< abort" *** CLASS-SIZE given a class that never had its .CLASS-SIZE field set by END-CLASS ***" ;

: object-size ( object -- size )    
    @                                           \ -- class
    .class-size @ ;                             \ -- size
    
: class ( -- class offset )                     \ stream: class-name parent-name
    create  here            \ -- class
        ' >body             \ -- class parent
        dup check-class     \ -- class parent                   \ make sure PARENT is a class
        dup ,               \ -- class parent   \ .class-parent
        -1 ,                \ -- class parent   \ .class-size   \ this will get filled in by END-CLASS
        class-id ,          \ -- class parent   \ .class-id     \ this is for error-checking
        class-size          \ -- class offset
    does> ( 'alloc -- adr )                     \ make a new object ( 'ALLOC is either HEAP-NEW or DICT-NEW)
        >r                                      \ 'alloc --             \ r: -- class
        r@ class-size  swap execute             \ -- object
        dup  r@ class-size  erase                               \ zero out the object
        r>  over ! ;                                            \ first field of object is pointer to class
            
: end-class ( class offset -- )    
    over check-class                            \ make sure CLASS is a class
    swap .class-size ! ;
    
: <<is-a>> ( object target -- flag )    
    over check-class  over check-class
    = ;
    
: <is-a> ( object 'target -- flag )    
    swap @  swap >body  <<is-a>> ;

: is-a ( object -- flag )                       \ stream: target-class-name
    ' <is-a> ;
    
: [is-a] ( object -- flag )                     \ stream: target-class-name
    postpone [']  postpone <is-a> ;
immediate

: <<is-kind-of>> ( class target -- flag )
    swap                                        \ target class
    over check-class  over check-class
    begin  
        2dup = if  2drop  true exit then
        @                                       \ -- target parent      \ .class-parent is first field
        dup 0= if  2drop  false exit then
        again ;
    
: <is-kind-of> ( object 'target -- flag )
    swap @  swap >body  <<is-kind-of>> ;

: is-kind-of ( object -- flag )                 \ stream: target-class-name
    ' <is-kind-of> ;
    
: [is-kind-of] ( object -- flag )               \ stream: target-class-name
    postpone [']  postpone <is-kind-of> ;
immediate

: <childlike> ( object 'child -- new-object )
    >body >r                                    \ -- object             \ r: -- child-class
    r@  over @  <<is-kind-of>>  0= abort" *** <CHILDLIKE> object's class is not a parent of child-class ***"
    r@ class-size  realloc                      \ -- new-object
    r> over ! ;                                 \ -- new-object         \ class is object's first field
    
\ <CHILDLIKE> converts an object into a new class, which is a child of its old class.
\ The programmer must still fill in the child fields or otherwise update the object.
\ The new object isn't necessarily going to be at the same address as the old object.
    
: childlike ( object -- new-object )            \ stream: child-class-name
    ' <childlike> ;
    
: [childlike] ( object -- new-object )          \ stream: child-class-name
    postpone [']  postpone <childlike> ;
immediate

[toc] | [prev] | [next] | [standalone]


#50237

Fromhughaguilar96@gmail.com
Date2016-08-19 00:29 -0700
Message-ID<1d39db9b-c0e2-467b-9996-2f34a2dcb84f@googlegroups.com>
In reply to#50227
On Thursday, August 18, 2016 at 5:08:34 PM UTC-7, hughag...@gmail.com wrote:
> On Wednesday, August 17, 2016 at 11:13:30 PM UTC-7, franck....@gmail.com wrote:
> > btw, what you call is-a is generally called IS-KINDOF (isKindOf in Oforth).
> > 
> > is-a generally checks only if the object's class is the same but
> > does not check its parent classes.
> 
> Here is an updated version that changes IS-A to mean exactly that class, but now provides IS-KIND-OF to mean that class or any of its parents.

There was a bug in this code. I was doing IS-KIND-OF backwards. I have changed some names to make it more understandable (I was confused by the names previously; hence the bug).

I have a new version with these new features:
1.) IS-A and [IS-A] check if an object is a member of class.
2.) IS-CHILD-OF and [IS-CHILD-OF] check if an object has this class as an ancestor (may be more than one generation away).
3.) IS-PARENT-OF and [IS-PARENT-OF] check if an object has this class as a child (may be more than one generation away).
4.) BECOME and [BECOME] change an object into a new class (change its size and change its pointer to the new class). The new class must be either a parent or a child of the current class (may be more than one generation away) --- first use IS-CHILD-OF or IS-PARENT-OF respectively to make sure.

IS-CHILD-OF and IS-PARENT-OF are useful to check if BECOME can be used (don't use BECOME without checking lest you get a catastrophe). IS-CHILD-OF is also useful to determine of a parent's methods can be used on your object.

IS-A is mostly useful in situations like the hottie-counting program where we have a data-structure with data of several classes (presumably all in the same inheritance chain) and we want to handle them differently.

Here is the new bug-free version:



98769876 constant class-id  \ used to make sure a class is actually a class; must be a distinctive value

0
    w field .class-parent   \ pointer to parent class       \ must be first field
    w field .class-size     \ size of object
    w field .class-id       \ should always be CLASS-ID
constant class-struct

\ Every object has a W field in front which is a pointer to the class-struct for its class.

: check-class ( class -- )
    .class-id @  class-id <> abort" *** tried to use a class that wasn't actually a class ***" ;

: create-nada ( -- )        \ create a class that has no parent
    create
        nil ,                       \ .class-parent     \ there is no parent
        w ,                         \ .class-size       \ room for the object's pointer to its class-struct
        class-id ,                  \ .class-id         \ this is for error-checking
    does> ( -- )        
        true abort" *** it is illegal to make objects of class NADA ***" ;
        
create-nada nada            \ NADA is the only class that has no parent

\ NADA is only available so it can be the parent of classes that have no parent.
\ It is not really a class that can be used as such.

' alloc             constant heap-new           \ give this to the class to get a new object in the heap
' concrete-alloc    constant dict-new           \ give this to the class to get a new object in the dictionary

: class-size ( class -- size )    
    .class-size @
    dup 0< abort" *** CLASS-SIZE given a class that never had its .CLASS-SIZE field set by END-CLASS ***" ;

: object-size ( object -- size )    
    @                                           \ -- class
    .class-size @ ;                             \ -- size
    
: class ( -- class offset )                     \ stream: class-name parent-name
    create  here            \ -- class
        ' >body             \ -- class parent
        dup check-class     \ -- class parent                   \ make sure PARENT is a class
        dup ,               \ -- class parent   \ .class-parent
        -1 ,                \ -- class parent   \ .class-size   \ this will get filled in by END-CLASS
        class-id ,          \ -- class parent   \ .class-id     \ this is for error-checking
        class-size          \ -- class offset
    does> ( 'alloc -- adr )                     \ make a new object ( 'ALLOC is either HEAP-NEW or DICT-NEW)
        >r                                      \ 'alloc --             \ r: -- class
        r@ class-size  swap execute             \ -- object
        dup  r@ class-size  erase                               \ zero out the object
        r>  over ! ;                                            \ first field of object is pointer to class
            
: end-class ( class offset -- )    
    over check-class                            \ make sure CLASS is a class
    swap .class-size ! ;
    
: <<is-a>> ( object target -- flag )    
    over check-class  over check-class
    = ;
    
: <is-a> ( object 'target -- flag )    
    swap @  swap >body  <<is-a>> ;

: is-a ( object -- flag )                       \ stream: target-class-name
    ' <is-a> ;
    
: [is-a] ( object -- flag )                     \ stream: target-class-name
    postpone [']  postpone <is-a> ;
immediate

: <<is-child-of>> ( ancestor class -- flag )
    over check-class  over check-class
    begin  
        2dup = if  2drop  true exit then
        @                                       \ -- ancestor parent    \ .class-parent is first field
        dup 0= if  2drop  false exit then
        again ;
        
: <is-child-of> ( object 'ancestor )
    >body  swap @  <<is-child-of>> ;
        
: is-child-of ( object -- flag )                \ stream: ancestor-class-name
    '  <is-child-of> ;
    
: [is-child-of] ( object -- flag )              \ stream: ancestor-class-name
    postpone [']  postpone <is-child-of> ;
immediate

\ IS-CHILD-OF tests if the object has ANCESTOR as an ancestor, meaning that it can use ANCESTOR's methods.

: <is-parent-of> ( object 'child )
    >body  swap @  swap <<is-child-of>> ;
    
: is-parent-of ( object -- flag )               \ stream: child-class-name
    '  <is-parent-of> ;
    
: [is-parent-of] ( object -- flag )             \ stream: child-class-name
    postpone [']  postpone <is-parent-of> ;
immediate

\ IS-PARENT-OF tests if the object has CHILD as a child, meaning that it can be upgraded to be a CHILD.

: <become> ( object 'class -- new-object )    
    >body >r                                    \ -- object             \ r: -- class
    r@ class-size  realloc                      \ -- new-object
    r> over ! ;                                 \ -- new-object         \ class is object's first field

\ <BECOME> converts an object into a new class. 
\ The new class must either be an ancestor or a child of the object's class.
\ Use IS-CHILD-OF to find out if the object is a child of the new class (can be downgraded to the parent class).
\ Use IS-PARENT-OF to find out if the object is a parent of the new-class (can be upgraded to the child class).

: become ( object -- new-object )               \ stream: class-name
    ' <become> ;
    
: [become] ( object -- new-object )             \ stream: class-name
    postpone [']  postpone <become> ;
immediate

[toc] | [prev] | [next] | [standalone]


Page 2 of 3 — ← Prev page 1 [2] 3  Next page →

Back to top | Article view | comp.lang.forth


csiph-web