Replies: 5 comments 9 replies
-
Well, types are not only associated with variables. They are also associated with expressions. I don't think the Modula-3 approach to types is that unusual. It basically rests on the idea that types are (restricted) sets. Restricted in the sense that you can't make a type that contains completely arbitrary sets of values (for example, both references and integers, or even both integers and single-precision floating-point numbers). On the other hand, yes, the type system is designed to support OOP. The best reference to Modula-3 types is |
Beta Was this translation helpful? Give feedback.
-
On Thu, 2 Mar 2023, Duke Normandin wrote:
I didn't realize that CM3 was an OOP-centric language. I have severe
OOP-a-phobia! I quit Perl when Perl5 came out. Maybe I should stick with
Ulm's Oberon-2 or Free Pascal. Thanks for the link and your input!
I would neither CM3 nor Modula-3 call OOP-centric. Instead, OOP is a
pretty orthogonal feature of the type system in Modula-3. Modula-3 even
has no special syntax for object methods. Instead you reuse procedures.
That is, you can use a procedure for multiple method implementations (if
types fit) or you can call a procedure behind a method without using
object method call syntax at all. This is pretty useful if you want to
pass a procedure as an argument to another procedure.
|
Beta Was this translation helpful? Give feedback.
-
On 3/2/23 14:01, Duke Normandin wrote:
I didn't realize that CM3 was an OOP-centric language. I have severe OOP-a-phobia! I quit Perl when Perl5 came out. Maybe I should stick with Ulm's Oberon-2 or Free Pascal. Thanks for the link and your input!
I would call it OOP-optional. If you don't declare anything with the type
constructor OBJECT, you will not have to deal with inheritance, dispatching
calls, or any of that stuff. Just use RECORD and REF RECORD to do, for example
linked, heap-allocated data structure.
Do realize that the common word "object" is often used to mean any heap-allocated
chunk of data, or even a simple declared variable. When OOP got really faddish,
there were many people trying to be really with-it, just by redefining what they had
long been doing as "object-oriented", when it was not. For example, many falsely
redefined modular programming, with equivalents to interfaces-and-modules as OOP,
even C header files, if used in certain ways.
Not wanting to appear dated, the C++ folks conflated objects and structs into a
single messy thing they called a class, with a mix of both, with the result that
you can't tell a dispatching method call from a conventional procedure call by
looking at it. Each kind can optionally look like the other, and it's often
a long quest through transitive #include files to ascertain it.
See: https://queue.acm.org/detail.cfm?id=1028906.
In Modula-3, these are syntactically distinct, so you know right away whether
a call will go predictably to a fixed place or somewhere dynamic.
Don't get me wrong. I am a big advocate for using OOP techniques for certain
situations, and they can be very helpful in such cases. I don't remember a
software project of moderately large size that didn't benefit from OOP somewhere,
or would have, had the language supported it.
I was an early adopter of object orientation, acquiring and porting SIMULA-67
compilers for the machines available to me at the time. Anybody here old enough
to remember SIMULA-67? The 67 is a clue to its age. It was the first object-oriented
programming language, but it wasn't called that. Only later was that term
coined, and applied retroactively to it and newer.
As I say, OOP has some very appropriate applications, but OOP seems to have
engendered a very misguided cult. "Objects first", as a pedagogical method
(heh, heh) is, IMO, a disaster, as OOP objects have as prerequisites, all
manner of simpler constructs, and then add additional complexity on top of them.
So enjoy Modula-3 without OOP, if you like.
…
—
Reply to this email directly, view it on GitHub <#1159 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABSVZNH3QA722UMKAU2E2LDW2D4CDANCNFSM6AAAAAAVNYKM2I>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
On 3/2/23 15:31, Duke Normandin wrote:
|So enjoy Modula-3 without OOP, if you like.|
I'll stick with it.
BTW Rodney, everything you say about OOP I've also heard proclaim by the FP crowd. Just lurk in the Lisp irc channel for a while and you;ll get an ear full. LOL IMHO, they all their pros and cons; all are more or less suited for certain projects and each will appeal to an individual depending on how intuitive that language resonates with him.
I am a big fan of doing certain things in functional style, whether the language is
a so-called functional language or not. Modula-3 also supports this too, although
with less syntactic sugar than a functional language. Pointers to records, heap
allocation, and GC are a lot of what is really required. I have done a couple of
instrumented experiments on data structure implementations, functional and imperative
style, side-by-side and found worthwhile reductions in memory allocation, deallocation,
total copying (sum of client and implementation side), and retention, as well as
reduced compute time, in thousands of randomly generated operations.
I do, however, like the ability to occasionally do something imperative down at the
implementation level, while keeping the abstract view entirely functoinal, as seen
by client code. Partially lazy evaluation and exploitation of partially overlapping
objects are examples.
And, for client code, it can be dream, compared to imperative.
… I punched ny first PL/I code at McGill in 1968. 😱
—
Reply to this email directly, view it on GitHub <#1159 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABSVZNDHHZK6BJ5TN5CVHMTW2EGT3ANCNFSM6AAAAAAVNYKM2I>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I like ML.
For a big M3 example in functional style, see m3-libs/ordsets
…On 3/2/23 21:24, Duke Normandin wrote:
I don't mind scheme; but I enjoyed messing with newlisp <http://www.newlisp.org/>
Not a fan of OCAML or Haskell. A few people I've run across write functionally using C. In Modula-3 to do the same I suppose you'd need an interface(s) for the function "prototypes; an implementation module(s) to flesh them out; and a Main.m3 to daisy-chain the lot. I suppose.
—
Reply to this email directly, view it on GitHub <#1159 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABSVZNFQBVZAFD2URAFP6SDW2FP5DANCNFSM6AAAAAAVNYKM2I>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Reading: 2.2 Types in Nelson's book
Smells of OOP to me.
It seems to me that in other languages a "type" is an "attribute" associated with a variable.
e.x. "age" can be declared as a variable to contain only integers.
In M3, it seems to me that a type e.g. INTEGER belongs to an object called TYPE.
Am I understanding M3 TYPE correctly?
Beta Was this translation helpful? Give feedback.
All reactions