Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.forth > #22573
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: The current object |
| Date | 2013-05-14 01:10 +0200 |
| Organization | 1&1 Internet AG |
| Message-ID | <kmrrtk$8nm$1@online.de> (permalink) |
| References | (17 earlier) <518a3875$0$32117$14726298@news.sunsite.dk> <kmei8v$s5l$1@online.de> <518b7d47$0$32115$14726298@news.sunsite.dk> <kmm6b0$9bd$1@online.de> <518f7fbb$0$32105$14726298@news.sunsite.dk> |
Doug Hoffman wrote:
> The multiple inheritance version of FMS is modeled after a proven Forth
> MI object system that has been around for about 20 years. It is a
> flexible and effective system with a solid foundation. Perhaps some
> comparison tests to your multiple inheritance system could be run. Where
> can I download your MI system?
(rolling eyes) Oh man, I'm sketching something together! Can you imagine,
or do you need 20 years old code?
> Lua isn't a good example of multiple inheritance implementation IMO.
> Look at the example here:
>
> http://lua-users.org/wiki/MultipleInheritanceClasses
>
> class.CombinedAccount(SavingsAccount, CurrentAccount)
>
> myCombinedAccount = CombinedAccount()
> myCombinedAccount:deposit(2.00) ← Error, deposit is nil
>
> Lua apparently cannot resolve the deposit method and gives an error.
Yes, Lua has quite some shortcomings. That's not the point here. The point
here is that Lua handles method and ivars identical. That it has
difficulties to resolve this sort of multiple inheritance is not the point;
that's a quality of implementation issue. Just imagine it would handle them
correctly. Please!
> The same problem is automatically handled without error in FMS:
>
> :class Account
> var balance
> :m balance: ( -- n) balance @ ;m
> :m deposit: ( n -- ) balance +! ;m
> ;class
>
> :class SavingsAccount super{ Account }
> ;class
>
> :class CurrentAccount super{ Account }
> ;class
>
> :class CombinedAccount super{ SavingsAccount CurrentAccount }
> ;class
>
> CombinedAccount myCombinedAccount
>
> 2 myCombinedAccount deposit: \ no error, deposit to savings
Yes, that's a good illustration of the problem, though you don't seem to
understand that it is a problem. There should be only one balance, not two.
The mental idea is that the class Account has a balance, and each of the
subclasses don't have any ivars; it's all inherited from Account. Let's
say, your grandmother had a valuable porcellain vase. Both your father and
mother inherited it after your grandma died. How many vases are there?
Yes: Still just one. If your parents die, you will inherit it.
This duplication of ivars happens in other OOP languages with MI, and it is
considered a problem there.
>> If you treat ivars like methods, you should be able to do that, anyways.
>> However, if you don't, the thing above would not work.
>
> Of course it would work. &x is a message that returns an address when
> sent to an object of class foo. That address is used exactly as it was
> before the revision.
Note that this doesn't really work. For the user of an object, it's a black
box (you can't access the ivars directly), but for derived classes, it's a
"grey box" - you *can* access the ivars. This rework means you still can
use the object as before, but if you inherit from the class, and try to
access x, you'll fail.
>> &x is not some
>> address somewhere, it is a way to access the ivar x with @ and ! and
>> other memory words outside the method.
>
> That's the whole point that you miss. We can redesign the object so the
> internals of the object change, in this case the ivar named x is
> eliminated, but code using the object is not broken.
>
> An object is a black box. The internal state is accessed via messages.
> This is a concept that is fundamental to object programming, yet you
> keep wanting to treat it like functional programming.
No, the black box concept is one possible aspect of OOP. You are talking
about OOP like the five blind men about the elephant. Black box concepts
can be done with OOP or without OOP, they are however pretty alien to
Forth's philosophy. I understand why Leo Brodie has argued pretty strongly
against OOP 30 years ago. He was standing at the back of the elephant and
said "This is a huge pile of shit, and it stinks!" The fact that OOP is an
elephant is pretty much unquestioned ;-).
The black box concept does not mean you can't access ivars. It means that
when you can access ivars, they are part of the public interface. Example
here:
http://hyperspatial.com/2009/08/black-box/
This is typical Java code (where people access ivars like x and y from
outside), and yet, the author thinks it's a "black box".
> Due to user requests, FMS *does* provide for message-less ivar access
> from outside a class definition. I warn that it is not good practice.
> Debugging a class with the ivars exposed like that is fine, but I would
> return to message-access-only once the class is debugged. My
> preference, not an absolute requirement in FMS.
"Once the class is debugged"... you mean, once your code is debugged. You
instantiate an object, do something with it, and then you want to see the
internal state, because it doesn't react as supposed. It's not buggy, the
code accessing it is buggy, yet, introspection helps to debug the thing.
> I suppose we could also avoid sending messages in order to invoke an
> object's methods. That would eliminate the need for messages altogether
> and might even make some happy. I wouldn't call it OOP though.
Some people have called systems that did just that "OOP", too. Quite many,
actually. "Polymorphism? I don't need that!" This is the typical way
Forth OOP discussions go: Everybody tells you what you don't need, because
they don't need it.
> But this issue of not using messages is pretty far off the original
> topic of current-object >o and o>. I think I am done with this.
Actually, that's not even remotely my point. I'm suggesting that you might
want to use the message passing system sometimes for ivars, too.
I want to find what people use to implement their OOP systems, and collect
these things as framework for implementing OOP systems. The common response
I get here is the "I don't need this, nobody should need this". And
everybody has his particular view of OOP.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-01 17:01 +0000
Re: The current object (was: Went open source with my GA144 ...) albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-05-01 19:20 +0000
Re: The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-02 17:02 +0000
Re: The current object (was: Went open source with my GA144 ...) Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-02 02:12 +0200
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-02 04:52 -0400
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-02 04:31 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-02 18:25 +0200
Re: The current object anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-02 16:58 +0000
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-02 22:26 +0200
Re: The current object anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-06 14:52 +0000
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 03:47 +0200
Re: The current object anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-07 15:22 +0000
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-02 12:12 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-02 21:56 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-03 03:19 -0500
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-03 06:54 -0400
Re: The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-02 14:28 +0000
Re: The current object (was: Went open source with my GA144 ...) Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-02 19:58 +0200
Re: The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-03 16:50 +0000
Re: The current object (was: Went open source with my GA144 ...) Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-04 18:58 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-04 13:35 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-05 01:08 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-04 18:29 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-05 03:00 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-05 03:48 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-05 23:15 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-06 05:01 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 03:23 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-07 03:39 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 19:00 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-07 13:34 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 22:00 +0200
Re: The current object anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-08 07:26 +0000
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-05 06:39 -0400
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-05 09:15 -0500
Re: The current object Paul Rubin <no.email@nospam.invalid> - 2013-05-05 09:25 -0700
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-05 11:43 -0500
Re: The current object Paul Rubin <no.email@nospam.invalid> - 2013-05-05 09:59 -0700
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-06 05:06 -0500
Re: The current object Mark Wills <forthfreak@gmail.com> - 2013-05-06 00:19 -0700
Re: The current object "WJ" <w_a_x_man@yahoo.com> - 2013-05-13 22:45 +0000
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-05 06:39 -0400
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-05 23:40 +0200
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-05 06:39 -0400
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-05 23:29 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-06 05:10 -0500
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-08 07:35 -0400
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-09 00:06 +0200
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-09 06:41 -0400
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-11 21:31 +0200
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-12 07:40 -0400
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-14 01:10 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-14 03:58 -0500
Re: The current object anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-14 14:51 +0000
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-15 03:48 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-14 18:37 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-14 14:42 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-15 00:22 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-15 02:56 -0500
Re: The current object stephenXXX@mpeforth.com (Stephen Pelc) - 2013-05-15 13:52 +0000
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-15 17:58 +0200
Re: The current object albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-05-17 14:01 +0000
Re: The current object johno <email@address.com> - 2013-05-15 22:38 +0100
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-14 06:27 -0400
Re: The current object albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-05-09 16:06 +0000
Re: The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-06 16:12 +0000
Re: The current object (was: Went open source with my GA144 ...) Alex McDonald <blog@rivadpm.com> - 2013-05-06 10:25 -0700
Re: The current object (was: Went open source with my GA144 ...) Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 04:00 +0200
Re: The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-07 15:02 +0000
Re: The current object (was: Went open source with my GA144 ...) Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 04:09 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-07 03:41 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 19:02 +0200
Re: The current object (was: Went open source with my GA144 ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-07 14:33 +0000
Re: The current object (was: Went open source with my GA144 ...) Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-07 19:40 +0200
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-15 16:46 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-15 13:11 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-15 23:23 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-16 02:24 -0500
Re: The current object anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-16 13:55 +0000
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-16 17:45 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-18 05:13 -0500
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-18 06:43 -0400
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-18 10:03 -0500
Re: The current object Doug Hoffman <glidedog@gmail.com> - 2013-05-18 11:30 -0400
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-19 01:20 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-19 12:33 -0500
Re: The current object Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-19 01:07 +0200
Re: The current object Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-19 03:58 -0500
OO dispatch (was: The current object) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-16 14:07 +0000
Re: OO dispatch Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-18 05:28 -0500
Re: OO dispatch anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-20 11:28 +0000
Re: OO dispatch Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-20 09:00 -0500
Re: OO dispatch Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-21 01:37 +0200
Re: OO dispatch Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-21 03:21 -0500
Re: OO dispatch anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-21 12:24 +0000
Re: OO dispatch Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-21 10:18 -0500
Re: OO dispatch anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-05-21 16:03 +0000
Re: OO dispatch Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-05-21 12:55 -0500
Re: OO dispatch Bernd Paysan <bernd.paysan@gmx.de> - 2013-05-29 00:00 +0200
Re: OO dispatch Mark Wills <markrobertwills@yahoo.co.uk> - 2013-05-28 15:49 -0700
csiph-web