Hello, I start to get a feeling of Oberon's style (I guess). Seems it requires programmers to build their toolkit, even for very basic, everyday, all-purpose, little tiny tasks (even more than eg Lua, which reputation reads "DIY"). Comments? Some details still escape my understanding, esp. around open arrays -- again. -1- form of actual parameter Since one cannot have a VAR of open array type, what is the actual form of an open array parameter, in the call expression? I tried the "[...]" format used in some Pascal dialects to express open array constants, but it is refused. Side-question: is there a literal notation for arrays? for records? (eg like pascal consts, or var initialisation) -2- COPY vs assignment The following is accepted by obc but refused by oo2c [EDIT: the opposite, in fact!]. Note that t1 & t2 share a unique & named type. In the latter case, I need to use COPY instead of :=. MODULE trial; TYPE ToChars = POINTER TO ARRAY OF CHAR; VAR i : INTEGER; t1,t2 : ToChars; BEGIN NEW(t1,3) ; NEW(t2,3); FOR i := 0 TO 2 DO t1[i] := CHR(97+i) END; t2[3] := 0X; t2 := t1; (* COPY(t1^,t2^); *) (* output routine *) END trial. But COPY removes the last element by replacing it with 0X, whatever lies there in the source array. My use case is a flexible array, of which a char sequence is only a particuliar case, which holds a 'size field' (so that getting the size does not require sequence traversal). Also, arrays of chars are commonly used as byte sequences. (Even more on Oberon since there is no BYTE?) Is there a way to make assignement work between all kinfs of open arrays? -2- size & copy Assignment/copy between arrays of different sizes does not seems to be possible, or at least I could not have it work (neither is the case where dest >source, nore the opposite). About COPY, the report says the dest if truncated if necessary, but even this does not work with the compilers I use. Is there a way to express: a2 := a1[i..j]; a2[i..j] := a1; ? -4- allocation Say I'm writing a func returning the indices of occurrences of a given element in a collection. I guess the only possible return type is a pointer to an open array. Correct? But how to allocate it (NEW(indices,size)), since its size is also a result of the process (collection traversal)? The only solution I found is two traverse twice ;-): once to count and then allocate, once to feed the array. off-topic: * is it possible to rename imported procs (eg "Write := Out.String" :-)? * alternatives to "(**)" such as "{}" or "//"? My editor deals badly with "(**)", transforming comments into visual pollution; and not permitting comment-in/out toggling. Denis ________________________________ vit esse estrany ☣ spir.wikidot.com
On Thu, Jun 24, 2010 at 10:49 AM, spir <denis.spir@gmail.com> wrote:
Hello,
I start to get a feeling of Oberon's style (I guess). Seems it requires programmers to build their toolkit, even for very basic, everyday, all-purpose, little tiny tasks (even more than eg Lua, which reputation reads "DIY"). Comments?
There are libraries in C, for example. Things such as toupper, that are primitive operations that are not part of the language, but part of the environment. These have to be supplied for very basic everyday little tiny tasks. To a programmer who is new to the C ecosystem, these are mysterious and frustrating. Oberon has its own libraries, and some of them are also very basic and primitive. If you want to do things the same way they are done in a different ecosystem you both can and must port a lot of stuff to make Oberon work that way. Of course, people who have used Oberon for some time just want to cry and bang their head against the wall whenever they face people who want to take a step decades backward to those ways of doing things. Oberon is both more powerful and much easier to use, provided that you are working in the Oberon thought patterns, not trying to translate everything back to patterns from some other language. It is probable that the library exists that will allow you to program a solution to whatever problem you are trying to solve. The trick is to read and become fluent in the knowledge of these libraries. This is true for any language choice.
Some details still escape my understanding, esp. around open arrays -- again.
-1- form of actual parameter
Since one cannot have a VAR of open array type, what is the actual form of an open array parameter, in the call expression? I tried the "[...]" format used in some Pascal dialects to express open array constants, but it is refused. Side-question: is there a literal notation for arrays? for records? (eg like pascal consts, or var initialisation)
I just compiled and executed a program using open array types, see below. Sometimes it is necessary to keep a distinction between pointers to open arrays, and var pointers to open arrays. This is the source of a lot of trouble in programming, and in Oberon the compiler is kind enough to bring your attention immediately to the buggy code and wait for you to fix it. This strikes many of us as far better than spending 3 weeks looking at core dump before we finally focus on the equivalent line of code.
-2- COPY vs assignment
The following is accepted by obc but refused by oo2c [EDIT: the opposite, in fact!]. Note that t1 & t2 share a unique & named type. In the latter case, I need to use COPY instead of :=.
MODULE trial; TYPE ToChars = POINTER TO ARRAY OF CHAR; VAR i : INTEGER; t1,t2 : ToChars; BEGIN NEW(t1,3) ; NEW(t2,3); FOR i := 0 TO 2 DO t1[i] := CHR(97+i) END; t2[3] := 0X; t2 := t1; (* COPY(t1^,t2^); *) (* output routine *) END trial.
But COPY removes the last element by replacing it with 0X, whatever lies there in the source array. My use case is a flexible array, of which a char sequence is only a particuliar case, which holds a 'size field' (so that getting the size does not require sequence traversal). Also, arrays of chars are commonly used as byte sequences. (Even more on Oberon since there is no BYTE?) Is there a way to make assignement work between all kinfs of open arrays?
This code allocates space for two arrays, pointed to by t1 and t2. It then orphans the array pointed to by t2, and makes both t1 and t2 point to the same memory. The Oberon 2 Report discusses COPY in 10.3 Predeclared procedures. My reading is that COPY works when the underlying array element is a CHAR. I suspect it stops at the first 0X character in most implementations. The whole Oberon system is expressed with strings that don't contain an internal 0X character. For other arrays, the iterating axillary variable is always used. The philosophy here is that the source code tells the human reader what is going on in the machine code. So your FOR loop over i is the usual way to do this. It compiles to very compact code, it is easy to read, and no surprises happen due to a compiler optimization.
-2- size & copy
Assignment/copy between arrays of different sizes does not seems to be possible, or at least I could not have it work (neither is the case where dest >source, nore the opposite). About COPY, the report says the dest if truncated if necessary, but even this does not work with the compilers I use. Is there a way to express: a2 := a1[i..j]; a2[i..j] := a1; ?
Again, this is expressed with explicit index variables. Something like a2[k] := a1[k+i] with guards for the beginning and ending values.
-4- allocation
Say I'm writing a func returning the indices of occurrences of a given element in a collection. I guess the only possible return type is a pointer to an open array. Correct? But how to allocate it (NEW(indices,size)), since its size is also a result of the process (collection traversal)? The only solution I found is two traverse twice ;-): once to count and then allocate, once to feed the array.
I would use a link list for this problem. If you need to interface to code that chose the array solution, then I usually create the link list, and feed the array from the list, not a new traversal.
off-topic: * is it possible to rename imported procs (eg "Write := Out.String" :-)?
Generally, anything that interferes with the ability to look at a page of printout and understand things is not allowed. If you obscure the name of the module that does the importing or the procedure name, this interferes with the "face of the document" interpretation.
* alternatives to "(**)" such as "{}" or "//"? My editor deals badly with "(**)", transforming comments into visual pollution; and not permitting comment-in/out toggling.
Denis ________________________________
vit esse estrany ☣
spir.wikidot.com -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
MODULE test2; IMPORT SYSTEM, Out; TYPE Array = ARRAY OF CHAR; CONST RomValues = 'Example is good.'; VAR ramcopy : ARRAY 32 OF CHAR; PROCEDURE MakesChangeTo (VAR array : Array; ix : INTEGER); VAR aux : POINTER TO Array; BEGIN NEW (aux, LEN(array)); COPY(array, aux^); array [ix] := CAP(array[ix]); Out.String (array); Out.Ln END MakesChangeTo; PROCEDURE NoChangeTo (array : Array); BEGIN array [6] := CAP (array[6]); Out.String (array); Out.Ln END NoChangeTo; BEGIN ramcopy := 'Example is good.'; NoChangeTo (RomValues); MakesChangeTo (ramcopy, 8); MakesChangeTo (ramcopy, 11); END test2. -- -- Aubrey McIntosh, Ph.D. 1502 Devon Circle Austin TX 78723-1814 http://home.grandecom.net/~amcintosh/aubrey/Search/
-1- form of actual parameter
Since one cannot have a VAR of open array type, what is the actual form of an open array parameter, in the call expression? I tried the "[...]" format used in some Pascal dialects to express open array constants, but it is refused.
I think you may have misunderstood the purpose of the open array in Oberon. It is provided so that you can develop a general procedure that allows you to process arrays of the same type but different lengths. e.g. TYPE DailyCount = ARRAY 7 OF INTEGER; MonthlyCount = ARRAY 12 OF INTEGER; VAR passengers: MonthlyCount; trains: DailyCount; In Pascal you would have needed a separate functions for each data type e.g. DailySort(VAR data: DailyCount); MonthlySort(VAR data: MonthlyCount); After Pascal came Modula-2 (and then Oberon) where you can define a generic procedure as: Sort(VAR data: ARRAY OF INTEGER); you can then call: Sort(passengers); or Sort(trains); NOTE: Unlike languages like C you do NOT need to pass an additional parameter to tell the procedure how long the array is. The Sort procedure can use the built-in LEN function to access that information.
Side-question: is there a literal notation for arrays? for records? (eg like pascal consts, or var initialisation)
The only literal notation for arrays in Oberon are string constants. This is a regular thorny question. Just a few days ago I came across a similar question in the ARMExpress Yahoo Group: // I'm looking for some feedback on a "quick and dirty" way to add an array of // constants to ARMbasic. // // VB has a way to initialize and array // // DIM x as INTEGER() = New Integer {1,2,3,4} My response was: First of all you need to decide what range of tasks you are trying to support with this type construct, and what it is NOT designed to be used for. For your simple small example {1,2,3,4} I can't really see that such a feature is necessary. I would have just initialised this with a loop to make it clear to the reader that there was a pattern (assuming there is?) to the data. Even if the four values had been random it is no big deal to have four assignment statements. It is fairly straightforward to design a system to just handle small one-dimension arrays of integers but that does not extend well to more complex data structures e.g. 3-dimensional arrays, arrays of records (structures) etc. etc. and is also unmaintainable once you go beyond a number of items that you can quickly count (e.g. 10 or so). e.g. how long does it take you to tell me what the 19th value is: {1,5,2,6,4,1,4,7,8,5,4,8,2,6,9,0,5,3,4,2,5,2} Now, are you *really* sure that was the 19th value?. You have to count at least twice. We had to find a way of handling the same situation with Astrobe as the only structured constant in Oberon-07 is a string. Also having seen the way this facility is often abused in C - humongous constant sections that embed images, fonts etc. in source code, using programs that convert the binary data to a text form, we went for a different approach in Astrobe. Typically on a PC system, this sort of constant data would be stored in a file to be read at runtime or as a 'resource file' embedded in the executable. The solution we use has features from both. We handle large blocks of constant data by gathering together all of the relevant data files (binary data, images, fonts etc.) at link time and appending them to the linked executable to be stored in Flash ROM when the program is uploaded. A library module ResData is provided to allow the programmer to conveniently access the data, as indexed data, from Flash ROM within the program as if it were data stored in a random-access disk file. Regards, Chris Burrows CFB Software Astrobe: ARM Oberon-07 Development System http://www.astrobe.com
On Fri, 25 Jun 2010 10:31:16 +0930 "Chris Burrows" <chris@cfbsoftware.com> wrote:
-1- form of actual parameter
Since one cannot have a VAR of open array type, what is the actual form of an open array parameter, in the call expression? I tried the "[...]" format used in some Pascal dialects to express open array constants, but it is refused.
I think you may have misunderstood the purpose of the open array in Oberon. It is provided so that you can develop a general procedure that allows you to process arrays of the same type but different lengths.
e.g.
TYPE DailyCount = ARRAY 7 OF INTEGER; MonthlyCount = ARRAY 12 OF INTEGER;
VAR passengers: MonthlyCount; trains: DailyCount;
In Pascal you would have needed a separate functions for each data type e.g.
DailySort(VAR data: DailyCount); MonthlySort(VAR data: MonthlyCount);
After Pascal came Modula-2 (and then Oberon) where you can define a generic procedure as:
Sort(VAR data: ARRAY OF INTEGER);
you can then call:
Sort(passengers);
or
Sort(trains);
NOTE: Unlike languages like C you do NOT need to pass an additional parameter to tell the procedure how long the array is. The Sort procedure can use the built-in LEN function to access that information.
Thank you. This is indeed a valuable feature, one that very often matches semantic & practicle needs. But literal notation for (bounded & open) arrays is still a helpful feature imo. Also, it does not make a language of lesser quality, I guess (eg less clear, or secure). Since in Oberon open arrays cannot be used for return values, CONSTs, or VARs (including records fields, which can be regarded as variables living in a given namespace, like ones defined in an imported module), I guess remain the only cases of: * instances of POINTER TO ARRAY OF SOMETYPE * open array actual parameters The first case can be seen, maybe, as a workaround for the absence of open array CONSTs and VARs. At least, this is how I use such types: I would prefere to define a VAR indices as ARRAY OF INTEGER and access it directly. For actual parameters, the question of how to (pre-)define a given open array has no solution, I guess. Eg to define one via a loop would require a sequence to traverse, which in turn would have to be an array... Probably the reason why numerous Pascal variants had at least a literal notation for open array actual parameters: type Integers = array of Integer procedure DoSomethingWith(integers:Integers); ... procedure testDoSomething; ... DoSomethingWith([1,3,9,33,99]); ... The only alternative beeing to have one CONST for _each_ test case, provided the language has a literal notation for CONST arrays (or one VAR for each when the language has a syntax for array VAR intialisation): this is --stupid-- tedious. But Oberon has none of those solution, or do I miss an obvious point? This "feature" easily turns a 10-line test routine into a 100-line one, and far less readable. Or will the programmer choose to avoid proper testing precisely because it be so tedious? (I'm unsure of the correctness of the last sentence.)
Side-question: is there a literal notation for arrays? for records? (eg like pascal consts, or var initialisation)
The only literal notation for arrays in Oberon are string constants. This is a regular thorny question. Just a few days ago I came across a similar question in the ARMExpress Yahoo Group:
// I'm looking for some feedback on a "quick and dirty" way to add an array of // constants to ARMbasic. // // VB has a way to initialize and array // // DIM x as INTEGER() = New Integer {1,2,3,4}
My response was:
First of all you need to decide what range of tasks you are trying to support with this type construct, and what it is NOT designed to be used for.
Your relevant question let me think for a while. I can see 3 application fields of structured data literal notation (in Oberon: arrays and records): 1. true constants: predefined data 2. trials, examples, prototyping 3. debugging & maintenance: test cases, test suites But the critical point for a "Wirth language" may be pedagogy, since those languages have pedagogy at least as important target field. Learning & teaching, I guess, really benefit from point 2. Point 1 & 3 are also helpful, if only as good practices. I personly do not primarily look for for a good pedagogical language, and do not explore & use Wirth languages for this reason. Rather, my reasoning is reverse: a good language can only be good for pedagogy. PL qualities required for pedagogy: clarity, consistency, simplicity (without sacrificing distinction of meaningful notions), are IMO the same ones required for real-world modelling, implementation, and maintenance. Only features of lower importance may be dsicussed (eg less verbose or less constrained grammar for production), but even this is doubtful. Maybe it's only me.
For your simple small example
{1,2,3,4}
I can't really see that such a feature is necessary. I would have just initialised this with a loop to make it clear to the reader that there was a pattern (assuming there is?) to the data. Even if the four values had been random it is no big deal to have four assignment statements.
Yes, but a loop cannot be used when there is no (obvious) scheme. And {1,2,3,4} is much clearer than four assignments (not to evoke compacity). Python, which was greatly inspired by Pascal, and also had pedagogical roots (both from Pascal and ABC), provides literal notation for all builtin types, associative tables included; not by chance. [The only missing feature of python regarding this point (as opposed to Lua) is a notation for single objects, like eg o=(x:1, y:'a'). Pythonists use dictionaries instead (o={'x':1, 'y':'a'}), but this is both semantically wrong (p is a kind of named tuple, not a collection) and far less clear & practicle (o['x'] instead of o.x).]
It is fairly straightforward to design a system to just handle small one-dimension arrays of integers but that does not extend well to more complex data structures e.g. 3-dimensional arrays, arrays of records (structures) etc. etc. and is also unmaintainable once you go beyond a number of items that you can quickly count (e.g. 10 or so).
e.g. how long does it take you to tell me what the 19th value is:
{1,5,2,6,4,1,4,7,8,5,4,8,2,6,9,0,5,3,4,2,5,2}
Now, are you *really* sure that was the 19th value?. You have to count at least twice.
We had to find a way of handling the same situation with Astrobe as the only structured constant in Oberon-07 is a string. Also having seen the way this facility is often abused in C - humongous constant sections that embed images, fonts etc. in source code, using programs that convert the binary data to a text form, we went for a different approach in Astrobe.
Typically on a PC system, this sort of constant data would be stored in a file to be read at runtime or as a 'resource file' embedded in the executable. The solution we use has features from both. We handle large blocks of constant data by gathering together all of the relevant data files (binary data, images, fonts etc.) at link time and appending them to the linked executable to be stored in Flash ROM when the program is uploaded.
A library module ResData is provided to allow the programmer to conveniently access the data, as indexed data, from Flash ROM within the program as if it were data stored in a random-access disk file.
This solution let me think at another, very impotant imo, use field: a literal notation for structured data turns a PL language into a data-description language when needed. This feature is extremely useful eg in Lua, for instance in the field of games: a game description script is a Lua program mainly holding data definition statements. The fact that Lua is also a complete PL allows making the script (thus, the game) truely dynamic. A difference with plain data desc langs like XML is that is the case of a true PL, the (implementation of the) language itself is the reader. As a another typical case, an application's config file is the description of data elements in the language's own format, generated by the app itself. No need to parse the file and construct config data: an import does the job, implicitely using the language's own parser and interpreter to "load" data. These data can even be of custom types, provided a module defining these types is imported before the data; or the type desc lies in the imported data module itself: -- module figures Position = {...} Color = {...} Point = {...} ... center = Point { position = Position {x=0,y=0}, color = Color {H=0,S=0,S=50}, -- medium grey visible = true, } Note: the pedagogical potential of data description seems to me huge. Such a wonderful feature is indeed _not_ to use without care in case the data are read from external sources ;-) (security)
Regards, Chris Burrows CFB Software
Astrobe: ARM Oberon-07 Development System http://www.astrobe.com
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Regards, Denis ________________________________ vit esse estrany ☣ spir.wikidot.com
-----Original Message----- From: oberon-bounces@lists.inf.ethz.ch [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of spir Sent: Friday, 25 June 2010 1:20 AM To: Oberon Subject: [Oberon] concrete use of open array
off-topic: * is it possible to rename imported procs (eg "Write := Out.String" :-)?
I agree with the spirit of Aubrey's reply. Keep in mind that programming is a WORM (i.e. write-once, read-many) exercise. Well maybe not 'once' but typically in these days of open source, the number of times source code is read far outweighs the number of times it is written. Hence, if ease of identification / location of an imported procedure (and protection against unintentional ambiguity) takes a little extra typing effort then that is well-justified. Having said that, typically in Oberon programs you will find many application-specific local 'helper' functions to handle the cases where the same imported function is called many times. Procedure calls in Oberon are efficient so there is no need to avoid writing small procedures (even one-liners) if there is a good reason to do so. Typical Oberon programs have procedures like: PROCEDURE WrError(errorCode: INTEGER; msg: ARRAY OF CHAR); BEGIN Out.String("Error: "); Out.Int(errorCode, 0); Out.String(": "); Out.String(msg); Out.Ln END WrError; so you can then write: WrError(309, "unterminated comment"); WrError(310, "bad character"); However, if you *really* want to rename an imported function it can be done using procedure variables with very little additional overhead. Just don't tell anybody I encouraged you to do so! e.g. VAR Write: PROCEDURE (s: ARRAY OF CHAR); and then in the module initialisation code: BEGIN Write := Out.String; ... ----------------------- Note that the Procedure variable / Procedure type facility is primarily intended to be used when you want to modify the functionality of the subject procedure at runtime, or to pass a procedure as a parameter to a function to modify the behaviour of that function. For example, a Generic Sorting module could have the following definitions: TYPE Object* = POINTER TO RECORD END; CompareProc* = PROCEDURE (CONST a, b: Object): INTEGER; PROCEDURE Quick*(VAR a: ARRAY OF Object; compare: CompareProc; left, right: INTEGER); ------- Then in the client module that IMPORTs you would have: PROCEDURE CompareReals(r1, r2: REAL): INTEGER; BEGIN (* Returns r1 < r2: -1 r1 = r2: 0 r1 > r2: +1 *) END CompareReals; and the actual call would be: Sort.Quick(realData, CompareReals, 0, LEN(realData) - 1) -- Chris Burrows CFB Software Astrobe: ARM Oberon-07 Development System http://www.astrobe.com
On Fri, 25 Jun 2010 11:31:54 +0930 "Chris Burrows" <chris@cfbsoftware.com> wrote:
-----Original Message----- From: oberon-bounces@lists.inf.ethz.ch [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of spir Sent: Friday, 25 June 2010 1:20 AM To: Oberon Subject: [Oberon] concrete use of open array
off-topic: * is it possible to rename imported procs (eg "Write := Out.String" :-)?
I agree with the spirit of Aubrey's reply.
I do, too. But there are cases where renaming is justified, either because the proc is heavily used, or sometimes originally holds a wrongly chosen named (ambiguious, misleading, cryptic). I else tend to avoid renaming, or to make it clearly visible in module headers.
Keep in mind that programming is a WORM (i.e. write-once, read-many) exercise. Well maybe not 'once' but typically in these days of open source, the number of times source code is read far outweighs the number of times it is written. Hence, if ease of identification / location of an imported procedure (and protection against unintentional ambiguity) takes a little extra typing effort then that is well-justified.
Yes, a programming language is shared by a programming community --> importance of standards, and of respecting them. (This is also an argument for a PL to provide a set of all-purpose, everyday-needed tools (as opposed to domain-specific libs), so that they are shared by the community as well, instead of each one developping his/her own toolkit.)
Having said that, typically in Oberon programs you will find many application-specific local 'helper' functions to handle the cases where the same imported function is called many times. Procedure calls in Oberon are efficient so there is no need to avoid writing small procedures (even one-liners) if there is a good reason to do so. Typical Oberon programs have procedures like:
PROCEDURE WrError(errorCode: INTEGER; msg: ARRAY OF CHAR); BEGIN Out.String("Error: "); Out.Int(errorCode, 0); Out.String(": "); Out.String(msg); Out.Ln END WrError;
so you can then write:
WrError(309, "unterminated comment"); WrError(310, "bad character");
This is typically what I had in mind :-) Thank you for this relevant example.
However, if you *really* want to rename an imported function it can be done using procedure variables with very little additional overhead. Just don't tell anybody I encouraged you to do so!
e.g.
VAR Write: PROCEDURE (s: ARRAY OF CHAR);
and then in the module initialisation code:
BEGIN Write := Out.String; ...
Great! I thought at this possibility, but believed I needed to declare a type, first. (The way you show below.)
-----------------------
Note that the Procedure variable / Procedure type facility is primarily intended to be used when you want to modify the functionality of the subject procedure at runtime, or to pass a procedure as a parameter to a function to modify the behaviour of that function. For example, a Generic Sorting module could have the following definitions:
TYPE Object* = POINTER TO RECORD END; CompareProc* = PROCEDURE (CONST a, b: Object): INTEGER;
PROCEDURE Quick*(VAR a: ARRAY OF Object; compare: CompareProc; left, right: INTEGER);
-------
Then in the client module that IMPORTs you would have:
PROCEDURE CompareReals(r1, r2: REAL): INTEGER; BEGIN (* Returns r1 < r2: -1 r1 = r2: 0 r1 > r2: +1 *) END CompareReals;
and the actual call would be:
Sort.Quick(realData, CompareReals, 0, LEN(realData) - 1)
Right, I will need such a pattern for higher-order funcs. Not that I appreciate the functional paradigm, but some match typical patterns, eg for collections (find --> element; filter, map --> collection; any, every --> boolean). I particuliarly like the clarity of code 'every' enables: IF numbers.every(isNaturalNumber) THEN ... IF objects.every(isNotNil) THEN ... IF inputData.every(isValid) THEN ... Thank you very much, Chris. Denis ________________________________ vit esse estrany ☣ spir.wikidot.com
-----Original Message----- From: oberon-bounces@lists.inf.ethz.ch [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of spir Sent: Friday, 25 June 2010 7:53 PM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] Renaming imported procs (was: concrete use of open array)
Right, I will need such a pattern for higher-order funcs. Not that I appreciate the functional paradigm, but some match typical patterns, eg for collections (find --> element; filter, map --> collection; any, every --> boolean). I particuliarly like the clarity of code 'every' enables: IF numbers.every(isNaturalNumber) THEN ... IF objects.every(isNotNil) THEN ... IF inputData.every(isValid) THEN ...
Thank you very much, Chris.
Denis
No problem. Something I should have mentioned earlier which might have answered some of your questions is to recommend Hanspeter Mössenböck's excellent book: "Object-Oriented Programming in Oberon-2": http://www.ssw.uni-linz.ac.at/Research/Books/ It can still be purchased from Amazon. If I had a $ for every time I'd recommended this book I'd be a rich man ;-) If you want a taste of what is in the book read his earlier paper with the same title which was presented at the 2nd International Modula-2 Conference. It can be downloaded in Postscript format from: http://www.ssw.uni-linz.ac.at/Research/Papers/Moe91.html Regards, Chris Burrows CFB Software http://www.cfbsoftware.com
--- spir.wikidot.com wrote
Right, I will need such a pattern for higher-order funcs. Not that appreciate the functional paradigm, but some match typical patterns, eg for collections (find --> element; filter, map --> collection; any, every --> boolean). I particuliarly like the clarity of code 'every' enables: IF numbers.every(isNaturalNumber) THEN ... IF objects.every(isNotNil) THEN ... IF inputData.every(isValid) THEN ...
You're right, Oberon does offer e.g. ARRAY OF REAL but no higher functions like "filter" or "every" that work on it natively. The good news however: these functions can be added if needed. The higher data type (Element, Collection..) and their corresponding functions (find, filter, every..) are encapsulated in a MODULE. Instantiation, input and output of those higher data structures should be handled in this MODULE as well. br Joerg
participants (4)
-
Aubrey.McIntosh@Alumni.UTexas.Net -
Chris Burrows -
Jörg Straube -
spir