I've been working on a lot of low-level STM32 microcontroller modules recently and have been finding the numerous references to SYSTEM are interfering with the readability. In an extreme case I have a module consisting of 45 statements which has 42 occurrences of the word SYSTEM! The next worst has 36 occurrences of SYSTEM in 47 statements. Consequently I'm investigating if there is a better way of doing this. 1. The programming language Oberon SA was the immediate predecessor of Oberon-07. It was specifically designed to be suitable for targeting realtime applications and was used to write the flight control software for model helicopters. Consequently there would have been extensive use of SYSYTEM functions. It eliminated the pseudo-module SYSTEM altogether and allowed procedures like PUT, GET and BIT to be called without a qualifier in the same way as ODD, INC etc. 2. I've seen others skirt around the problem by using S as an alias for SYSTEM. That seems like a half-baked solution / workaround to me. 3. Modula-2 had a number of different ways of relaxing explicit qualification of imported items. I much prefer Oberon's simpler, consistent, mechanism for all cases - except SYSTEM. I'd still like to retain the use of the SYSTEM pseudo-module SYSTEM qualifiers so that they stand out in a module where they only appear rarely and I do not want to modify the way other IMPORTs work. Consequently I'm thinking of implementing an extension to the Astrobe Oberon-07 compilers. This will allow low-level modules to be specified by prefixing the keyword MODULE with the keyword SYSTEM (similarly to the DEFINITION and IMPLEMENTATION module prefixes in Modula-2). Such system modules would allow / require any SYSTEM objects to be referenced unqualified. E.g. for the STM32 RTC functions: SYSTEM MODULE Clock; IMPORT MCU; CONST RTCBase = MCU.RTCBase; TR = RTCBase + 00H; ISR = RTCBase + 0CH; (* ISR bits *) RSF = 5; PROCEDURE* Seconds*(): INTEGER; VAR time: INTEGER; BEGIN REPEAT UNTIL BIT(ISR, RSF); GET(TR, time); RETURN 10 * UBF(time, 6, 4) + UBF(time, 3, 0) END Seconds; Instead of: PROCEDURE* Seconds*(): INTEGER; VAR time: INTEGER; BEGIN REPEAT UNTIL SYSTEM.BIT(ISR, RSF); SYSTEM.GET(TR, time); RETURN 10 * SYSTEM.UBF(time, 6, 4) + SYSTEM.UBF(time, 3, 0) END Seconds; Note: bitfield := UBF(word, msb, lsb) is an Astrobe SYSTEM function extension which replaces the UBFX, unsigned bitfield extract, function discussed here recently. Any comments? Any other suggestions for solving this problem?
Hi Chris,
I've ... been finding the numerous references to SYSTEM are interfering with ... readability. In an extreme case I have a module consisting of 45 statements which has 42 occurrences of the word SYSTEM! The next worst has 36 occurrences of SYSTEM in 47 statements. Consequently I'm investigating if there is a better way of doing this.
I thought as a halfway-house and keeping with the spirit of the language you might use WITH SYSTEM DO... but based on experience with Delphi I'm not overly enamoured with WITH anyway, I wrote about that before. Given that you are losing a lot of safety when using SYSTEM anyway, I'm wondering if removing the requirement for SYSTEM is a step in the wrong direction. I'd like to see some of the code you think has readability problems, bearing in mind that readability is in the eye of the beholder. :) Seriously of course, it's readability and comprehensibility to the *next* programmer (e.g. the one who tries to change it) which typically matters. Maybe SYSTEM. ain't that bad. I think in these days of entire function prototypes not even fitting in Intellisense popups, we might want to have some perspective here... :) Cheers, Paul
I fully understand both sides of the medal: - SYSTEM as marker that this module is not portable - SYSTEM as being cumbersome if you have a lot of those. Personally, I use IMPORT S:= SYSTEM as kind of compromise. You see the low level nature by IMPORTING it and in addition restrict the typing overhead to the minimum under the current syntax. Jörg
Am 10.11.2018 um 12:32 schrieb Paul Reed <paulreed@paddedcell.com>:
Hi Chris,
I've ... been finding the numerous references to SYSTEM are interfering with ... readability. In an extreme case I have a module consisting of 45 statements which has 42 occurrences of the word SYSTEM! The next worst has 36 occurrences of SYSTEM in 47 statements. Consequently I'm investigating if there is a better way of doing this.
I thought as a halfway-house and keeping with the spirit of the language you might use WITH SYSTEM DO... but based on experience with Delphi I'm not overly enamoured with WITH anyway, I wrote about that before.
Given that you are losing a lot of safety when using SYSTEM anyway, I'm wondering if removing the requirement for SYSTEM is a step in the wrong direction. I'd like to see some of the code you think has readability problems, bearing in mind that readability is in the eye of the beholder. :)
Seriously of course, it's readability and comprehensibility to the *next* programmer (e.g. the one who tries to change it) which typically matters. Maybe SYSTEM. ain't that bad. I think in these days of entire function prototypes not even fitting in Intellisense popups, we might want to have some perspective here... :)
Cheers, Paul
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Paul Reed Sent: Saturday, 10 November 2018 10:03 PM To: ETH Oberon and related systems Subject: Re: [Oberon] SYSTEM Modules
I thought as a halfway-house and keeping with the spirit of the language you might use WITH SYSTEM DO... but based on experience with Delphi I'm not overly enamoured with WITH anyway, I wrote about that before.
Delphi's WITH is scoped to a RECORD. It doesn't need to be that fine-grained in the case of SYSTEM. I believe that module scope is sufficient. Also the WITH syntax lends itself to be used with any IMPORT. I would want it to be restricted to SYSTEM - any other relaxation of the module qualifier rules sounds nice in theory but becomes a maintenance nightmare. E.g. in Project Oberon you can search for Files.Write and the results won't include Texts.Write. When you're maintaining an application with 100,000s lines of code composed of several hundred modules you really appreciate fully-qualified imports. I would argue that unqualified SYSTEM references are a special case. The distinction between built-in procedures like ORD and SYSTEM procedures like VAL, has become more blurred. Now that CHAR is implementation-defined, ORD is now implementation-dependent. Should that now be a SYSTEM function?
Given that you are losing a lot of safety when using SYSTEM anyway, I'm wondering if removing the requirement for SYSTEM is a step in the wrong direction. I'd like to see some of the code you think has readability problems, bearing in mind that readability is in the eye of the beholder. :)
Have a look at: http://www.astrobe.com/images/before.jpg http://www.astrobe.com/images/after.jpg Now I think about it, perhaps all I need to do is make the new bitfield procedures BFI and UBF built-in procedures rather than SYSTEM functions. After all they are no more unsafe or less portable than ASR, LSL and ROR? Regards, Chris Chris Burrows CFB Software http://www.astrobe.com
Chris: I like your observation that all these VAL, ORD, CHAR, ASR, LSL and ROR are on an equal footing. Why should some of these be SYSTEM, while others not? All of them are meant for some low level manipulation. And we just learned that DIV and MOD can be much the same way. I can see that DIV and MOD are primarily related to integer math, and their bit shifting functionality is a byproduct. So here I can see why DIV and MOD are operators and why they belong to the language. But all these other three letter acronyms? Why are they promoted to the language proper? And do not forget this LED please! If there is LED then BEEP should also be there. Adding BEEP to the language would not look serious to me. So it would make sense to make a decision that all these three letter things (other than DIV and MOD) belong to SYSTEM rather than just a few of them. Wojtek
All If I understand your reasoning correctly, you say: I happen to be a low level programmer and am confronted with the fact I have to write a lot of SYSTEM qualifiers in my code. As I don’t like that, lets modify the language. Now imagine I happen to be a programmer of a GUI and my code is full of Display qualifiers. I could for sure find a similar procedure as your InitClocks with 30 SYSTEM calls where I use 30 calls to Display procedures in a row. As I don‘t like that, lets modify the language. In the first case I would propose IMPORT S:=SYSTEM, for the second programmer I would propose IMPORT D := Display I like the Oberon idea of fully qualified names. The Modula syntax where you dequalify your names during the IMPORT by a list of procedures opens up a lot of confusion while maintaing different sources, with different dequalifying IMPORT lists. Just my 2cents Jörg
Am 11.11.2018 um 05:22 schrieb Skulski, Wojciech <skulski@pas.rochester.edu>:
Chris:
I like your observation that all these VAL, ORD, CHAR, ASR, LSL and ROR are on an equal footing. Why should some of these be SYSTEM, while others not? All of them are meant for some low level manipulation. And we just learned that DIV and MOD can be much the same way.
I can see that DIV and MOD are primarily related to integer math, and their bit shifting functionality is a byproduct. So here I can see why DIV and MOD are operators and why they belong to the language. But all these other three letter acronyms? Why are they promoted to the language proper?
And do not forget this LED please! If there is LED then BEEP should also be there. Adding BEEP to the language would not look serious to me.
So it would make sense to make a decision that all these three letter things (other than DIV and MOD) belong to SYSTEM rather than just a few of them.
Wojtek -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
I like the Oberon idea of fully qualified names. The Modula syntax where you dequalify your names during the IMPORT by a list of procedures opens up a lot of confusion while maintaing different sources, with different dequalifying IMPORT lists.
Yes, qualified name for ever! My idea in general is to avoid any change to the language, especially those constructs that demonstrated to create problems in maintainability. Why don't enhance IDE capabilities? For example an option "Hide SYSTEM qualified identifiers" and every "SYSTEM." visually disappear. Or being more general, a possibility to hide a particular qualified identifier of an imported module via a menu or via a particular comment (that only the IDE can interpret). IMPORT (* +HIDE *) Display; Another possibility is an IDE feature to wrap all exported procedures of an imported module. PROCEDURE Foo; BEGIN ImportedModule.Foo END Foo; The problem with this possibility is that it can't be applied to SYSTEM procedures because the language can't express some of them (PUT and GET are polymorphic, VAL requires a type name, etc..).
-----Original Message-----
From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of
Jörg Straube
Sent: Sunday, 11 November 2018 6:35 PM
To: ETH Oberon and related systems
Subject: Re: [Oberon] SYSTEM Modules
All
If I understand your reasoning correctly, you say: I happen to be a
low level programmer and am confronted with the fact I have to write
a lot of SYSTEM qualifiers in my code. As I don t like that, lets
modify the language.
Now imagine I happen to be a programmer of a GUI and my code is full
of Display qualifiers. I could for sure find a similar procedure as
your InitClocks with 30 SYSTEM calls where I use 30 calls to Display
procedures in a row.
As I don t like that, lets modify the language.
In the first case I would propose IMPORT S:=SYSTEM, for the second
programmer I would propose IMPORT D := Display
I like the Oberon idea of fully qualified names. The Modula syntax
where you dequalify your names during the IMPORT by a list of
procedures opens up a lot of confusion while maintaing different
sources, with different dequalifying IMPORT lists.
Just my 2cents
J rg
Not exactly. I'm questioning why some global built-in procedures have to be qualified whereas others don't. How cumbersome would it be if we had to say GLOBAL.INC(i, 1) or ch := GLOBAL.CHR(i)? The definition of SYSTEM has diminished over time to the point where it is now almost redundant. Comparing SYSTEM calls to Display calls is like comparing apples to oranges. Global built-in / SYSTEM procedures are very different to procedures contained in library or application modules. You cannot necessarily apply the same rules to both. Built-in procedures have one or more of the following attributes: 1. Variable number of parameters 2. Implemented as inline code 3. Bypass normal type-checking code 4. Bypass normal range-checking code And, above all: 5. They can only be modified / added to by modifying the compiler Whenever I have had a situation where there could be many calls to the same imported module (e.g. Texts, Display) etc, I wouldn’t use aliases just to save typing. e.g. if I see repetitive code like this Files.ReadInt(R, data); Out.String("fixP = "); Out.Int(data, 8); Out.Ln(); Files.ReadInt(R, data); Out.String("fixD = "); Out.Int(data, 8); Out.Ln(); Files.ReadInt(R, data); Out.String("fixT = "); Out.Int(data, 8); Out.Ln(); Files.ReadInt(R, data); Out.String("entry = "); Out.Int(data, 8); Out.Ln(); I am likely to refactor it to something like this: PROCEDURE ShowFixup(r: Files.Rider; label: ARRAY OF CHAR); VAR data: INTEGER; BEGIN Files.ReadInt(r, data); Out.String(label); Out.String(" = "); Out.Int(data, 8); Out.Ln(); END ShowFixup; ShowFixup(R, "fixP"); ShowFixup(R, "fixD"); ShowFixup(R, "fixT"); ShowFixup(R, "entry"); The dozen references to Out are reduced to four. Regards, Chris Burrows CFB Software http://www.astrobe.com
Is there a implementation of the Hayes AT command set done for Oberon? The wifichips of Espressif can use AT firmware. https://www.espressif.com/sites/default/files/documentation/4A-ESP8266_AT_In... I've experimented with modules rs232 and V24 on Native Oberon years ago. And I saw SCC for the nRF24L01 written by Paul. Did anyone try to connect Oberon (07/system) with internet through AT commands? Greets, F.P.
Hi FP,
Is there a implementation of the Hayes AT command set done for Oberon? Native PPP, yes.
The wifichips of Espressif can use AT firmware. https://www.espressif.com/sites/default/files/documentation/4A-ESP8266_AT_ Instruction_Set__EN.pdf
I doubt it. This is some wacky AT command set specifically for the 8266, e.g. AT+CWLAP "Lists Available [WiFi] APs", which seems to have zero in common with the Hayes AT command set, except the letters "AT". Cheers, Paul
On 11.11.18 12:03, Chris Burrows wrote:
I'm questioning why some global built-in procedures have to be qualified whereas others don't.
Isn't the distinction simple? Un-qualified built-in procedures (e.g. INC) provide safe functionality; qualified build-in procedures (e.g. SYSTEM.PUT) provide unsafe and potentially unportable functionality—which should be visible as such within the source code and be avoided if possible.
The definition of SYSTEM has diminished over time to the point where it is now almost redundant.
If this has happened, we should try to make the distinction clear again...
Global built-in / SYSTEM procedures are very different to procedures contained in library or application modules.
Of course they are! They are part of the language: an elegant solution to keep the syntax simple. Compare, for example, the simplicity of INC(x) and INC(x,7) to the strange C syntax of x++, ++x, and x+=7. Richard
Yes, safe/unsafe is the definition with the very prominent exception of ORD. The whole topic around „string, CHAR, CHR, ORD“ is - for me at least - not as elegant and simple as we would expect from NW. If NW wants to restrict CHAR to ASCII then he should have mention it in the report. But just leave it to the implementation and provide an implementation-dependet function like ORD unqualified is „not nice“... Jörg
Am 11.11.2018 um 15:42 schrieb Richard Hable <informujo@aon.at>:
On 11.11.18 12:03, Chris Burrows wrote:
I'm questioning why some global built-in procedures have to be qualified whereas others don't.
Isn't the distinction simple?
Un-qualified built-in procedures (e.g. INC) provide safe functionality; qualified build-in procedures (e.g. SYSTEM.PUT) provide unsafe and potentially unportable functionality—which should be visible as such within the source code and be avoided if possible.
The definition of SYSTEM has diminished over time to the point where it is now almost redundant.
If this has happened, we should try to make the distinction clear again...
Global built-in / SYSTEM procedures are very different to procedures contained in library or application modules.
Of course they are! They are part of the language: an elegant solution to keep the syntax simple. Compare, for example, the simplicity of INC(x) and INC(x,7) to the strange C syntax of x++, ++x, and x+=7.
Richard -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 11.11.18 22:35, Jörg Straube wrote:
Yes, safe/unsafe is the definition with the very prominent exception of ORD.
I don't see any unsafety with the ORD function: different systems use different characters sets, thus the resulting character code values can vary. Similarily, different systems use different line endings, thus the procedure Out.Ln may output an LF character on Unix-like systems and the CR/LF sequence on Windows systems. The programmer simply has to be aware of such differences. Richard
You‘re right. It’s not the safety I‘m referring to but rather the portability. Eg n := ORD(ch) - ORD(“A“); Out.Ch(ch); Out.String(“ is the “); Out.Int(n, 0); Out.String(„th character.); Will work with ASCII but not with EBCDIC. Jörg
Am 11.11.2018 um 23:02 schrieb Richard Hable <informujo@aon.at>:
On 11.11.18 22:35, Jörg Straube wrote:
Yes, safe/unsafe is the definition with the very prominent exception of ORD.
I don't see any unsafety with the ORD function: different systems use different characters sets, thus the resulting character code values can vary.
Similarily, different systems use different line endings, thus the procedure Out.Ln may output an LF character on Unix-like systems and the CR/LF sequence on Windows systems.
The programmer simply has to be aware of such differences.
Richard -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 12.11.18 06:40, Jörg Straube wrote:
You‘re right. It’s not the safety I‘m referring to but rather the portability.
Eg n := ORD(ch) - ORD(“A“); Out.Ch(ch); Out.String(“ is the “); Out.Int(n, 0); Out.String(„th character.);
Will work with ASCII but not with EBCDIC.
Maybe we should define portability as "portable as long as the programmer does not rely on undefined behavior"—like assuming a specific ordering of character codes in this case. And even the most portable programming languages contain undefined behavior. For example, the following Java code comparing references to objects of type Integer prints "equal" on my local installation: Integer x = 6; Integer y = 6; System.out.println(x == y ? "equal" : "not equal"); However, the following code prints "not equal": Integer x = 666; Integer y = 666; System.out.println(x == y ? "equal" : "not equal"); This is, because the implementation choses to re-use small integer objects, but allocate new objects for bigger objects. Other correct Java implementations may just as well chose to cache all values or none at all. Code which relies on one of these behaviors is potentially unportable; but that does not make Java's reference comparison feature unportable. Richard
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Richard Hable Sent: Monday, 12 November 2018 1:13 AM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] SYSTEM Modules
The definition of SYSTEM has diminished over time to the point where it is now almost redundant.
If this has happened, we should try to make the distinction clear again...
Agreed. If SYSTEM is restricted to unsafe and not just non-portable then the distinction is somewhat clearer. 1. PUT and COPY are undeniably unsafe. 2. ADR and GET are readonly so they are not inherently unsafe. However, they are required for PUT and COPY to be effective so they are unsafe by association. 3. VAL falls into the category of it depends ... SYSTEM.VAL(SET, intval), SYSTEM.VAL(CHAR, intval), SYSTEM.VAL(INTEGER, charval) are as harmless as ORD and CHR. All are inherently non-portable however. On the other hand, SYSTEM.VAL(INTEGER, pointerVal) is as unsafe as ADR. 4. BIT and SIZE I'm not so sure about. They are both readonly so I can't see how you could corrupt a system with their use. 5. BYTE used to be SYSTEM.BYTE but has now been promoted to be unqualified. 6. ASH used to be unqualified at the same time as ROT and LSL were SYSTEM procedures. I always thought that was somewhat inconsistent. They are now replaced with ASR, ROR and LSL. None of which need to be qualified by SYSTEM. Considering all of that I believe that the BFI and UBF bitfield procedures I am proposing to introduce are no more unsafe than ASR, ROR and LSL. Consequently they should not need to be qualified with SYSTEM. Now the language report explicitly accepts that 'individual implementations may include in their module SYSTEM additional definitions'. So adding these is not considered 'changing the language'. What I am not so sure about is whether the inclusion of additional non-system built-in procedures like BFI, UBF, BITS (i.e. SYSTEM.VAL(SET, intval)) would be considered to be 'changing the language'. However, as the language report freely admits that the RISC5 compiler includes the addition non-SYSTEM functions UML, SBC, ADC and LED that leads me to assume it that it is OK for others to do so as well - presumably as long as they are clearly documented as 'implementation-specific extensions'. Regards, Chris Burrows CFB Software http://www.astrobe.com
Chris I like your list. Normally, memory access should be done with pointers as theses have a type. Now, if you allow unqualifed GET, it could be seen as untyped memory access. In my point BIT is in SYSTEM as it depends on the endianess and hence is not portable. This is the difference to bit access via „IN“, where endianess is of no importance You correctly pointed out that in the past 1byte items were incorrectly declared as CHAR with al pros and cons of the character encoding. As the underlying HW supports items of 1byte and 4byte, NW allows BYTE now as standard numeric type to represent 1byte items and you can do arithmetic on it. To put BFI in SYSTEM for your ARM compiler is totally okay. As it is in SYSTEM everybody understands that code with SYSTEM.BFI has to be re-written for another CPU. However I‘m against putting BFI in an RISC5 compiler as ther is no RISC5 instruction. And emulating assembler code of on CPU on another CPU is bexond the scope of SYSTEM. Jörg Am 12.11.2018 um 08:53 schrieb Chris Burrows <chris@cfbsoftware.com>:
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Richard Hable Sent: Monday, 12 November 2018 1:13 AM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] SYSTEM Modules
The definition of SYSTEM has diminished over time to the point where it is now almost redundant.
If this has happened, we should try to make the distinction clear again...
Agreed. If SYSTEM is restricted to unsafe and not just non-portable then the distinction is somewhat clearer.
1. PUT and COPY are undeniably unsafe.
2. ADR and GET are readonly so they are not inherently unsafe. However, they are required for PUT and COPY to be effective so they are unsafe by association.
3. VAL falls into the category of it depends ...
SYSTEM.VAL(SET, intval), SYSTEM.VAL(CHAR, intval), SYSTEM.VAL(INTEGER, charval) are as harmless as ORD and CHR. All are inherently non-portable however.
On the other hand, SYSTEM.VAL(INTEGER, pointerVal) is as unsafe as ADR.
4. BIT and SIZE I'm not so sure about. They are both readonly so I can't see how you could corrupt a system with their use.
5. BYTE used to be SYSTEM.BYTE but has now been promoted to be unqualified.
6. ASH used to be unqualified at the same time as ROT and LSL were SYSTEM procedures. I always thought that was somewhat inconsistent. They are now replaced with ASR, ROR and LSL. None of which need to be qualified by SYSTEM.
Considering all of that I believe that the BFI and UBF bitfield procedures I am proposing to introduce are no more unsafe than ASR, ROR and LSL. Consequently they should not need to be qualified with SYSTEM.
Now the language report explicitly accepts that 'individual implementations may include in their module SYSTEM additional definitions'. So adding these is not considered 'changing the language'. What I am not so sure about is whether the inclusion of additional non-system built-in procedures like BFI, UBF, BITS (i.e. SYSTEM.VAL(SET, intval)) would be considered to be 'changing the language'.
However, as the language report freely admits that the RISC5 compiler includes the addition non-SYSTEM functions UML, SBC, ADC and LED that leads me to assume it that it is OK for others to do so as well - presumably as long as they are clearly documented as 'implementation-specific extensions'.
Regards, Chris Burrows CFB Software 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
-----Original Message----- From: Jörg Straube [mailto:joerg.straube@iaeth.ch] Sent: Monday, 12 November 2018 7:19 PM To: chris@cfbsoftware.com; ETH Oberon and related systems Subject: Re: [Oberon] SYSTEM Modules
In my point BIT is in SYSTEM as it depends on the endianess and hence is not portable. This is the difference to bit access via IN , where endianess is of no importance
My understanding is that Richard's proposition was that lack of portability alone was not sufficient to relegate a built-in procedure to SYSTEM. The procedure also had to be unsafe. I concur with that notion. In any case, endianess is no big deal. It is just one of many issues to be aware of if you are concerned about portability. As well as the traditional concerns about signed / unsigned data, sizes of numeric data, floating point formats etc. Oberon's SET size, character sets etc. are also now implementation-dependent. However, anybody who takes the time to understand the issues involved just needs to be alert not alarmed.
To put BFI in SYSTEM for your ARM compiler is totally okay. As it is in SYSTEM everybody understands that code with SYSTEM.BFI has to be re-written for another CPU. However I m against putting BFI in an RISC5 compiler as ther is no RISC5 instruction. And emulating assembler code of on CPU on another CPU is bexond the scope of SYSTEM.
Mapping to a RISC5 instruction is not a pre-condition for inclusion in either SYSTEM procedures or built-in procedures. Look at the code generated by SYSTEM.COPY, PACK and UNPK for example. Regards, Chris Burrows CFB Software http://www.astrobe.com
A suggestion: Rule: ADR, BIT, SIZE, PUT COPY GET can only be called in the module Kernel.Mod (Oberon system) and SYSTEM.Mod (embedded oberon) Greets, F.P. Chris Burrows schreef op 2018-11-12 08:53:
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Richard Hable Sent: Monday, 12 November 2018 1:13 AM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] SYSTEM Modules
The definition of SYSTEM has diminished over time to the point where it is now almost redundant.
If this has happened, we should try to make the distinction clear again...
Agreed. If SYSTEM is restricted to unsafe and not just non-portable then the distinction is somewhat clearer.
1. PUT and COPY are undeniably unsafe.
2. ADR and GET are readonly so they are not inherently unsafe. However, they are required for PUT and COPY to be effective so they are unsafe by association.
3. VAL falls into the category of it depends ...
SYSTEM.VAL(SET, intval), SYSTEM.VAL(CHAR, intval), SYSTEM.VAL(INTEGER, charval) are as harmless as ORD and CHR. All are inherently non-portable however.
On the other hand, SYSTEM.VAL(INTEGER, pointerVal) is as unsafe as ADR.
4. BIT and SIZE I'm not so sure about. They are both readonly so I can't see how you could corrupt a system with their use.
5. BYTE used to be SYSTEM.BYTE but has now been promoted to be unqualified.
6. ASH used to be unqualified at the same time as ROT and LSL were SYSTEM procedures. I always thought that was somewhat inconsistent. They are now replaced with ASR, ROR and LSL. None of which need to be qualified by SYSTEM.
Considering all of that I believe that the BFI and UBF bitfield procedures I am proposing to introduce are no more unsafe than ASR, ROR and LSL. Consequently they should not need to be qualified with SYSTEM.
Now the language report explicitly accepts that 'individual implementations may include in their module SYSTEM additional definitions'. So adding these is not considered 'changing the language'. What I am not so sure about is whether the inclusion of additional non-system built-in procedures like BFI, UBF, BITS (i.e. SYSTEM.VAL(SET, intval)) would be considered to be 'changing the language'.
However, as the language report freely admits that the RISC5 compiler includes the addition non-SYSTEM functions UML, SBC, ADC and LED that leads me to assume it that it is OK for others to do so as well - presumably as long as they are clearly documented as 'implementation-specific extensions'.
Regards, Chris Burrows CFB Software 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
On 12.11.18 08:53, Chris Burrows wrote:
2. ADR and GET are readonly so they are not inherently unsafe. However, they are required for PUT and COPY to be effective so they are unsafe by association.
Also, even trying to get an integer represenation of the address of a variable may fail—for example, if the variable is stored in a register, or non-linear memory space is used. And trying to read from memory can crash the program due to wrong alignment or access to a protected memory area.
3. VAL falls into the category of it depends ...
SYSTEM.VAL(SET, intval), SYSTEM.VAL(CHAR, intval), SYSTEM.VAL(INTEGER, charval) are as harmless as ORD and CHR. All are inherently non-portable however.
Contrary to ORD and CHR they also break type safety.
4. BIT and SIZE I'm not so sure about. They are both readonly so I can't see how you could corrupt a system with their use.
BIT tries to read memory, so it belongs into the same group as GET. SIZE seems to be useful only for preparing "unsafe" operations. But I agree that the distinction between "safe" and "unsafe" is not always obvious. Maybe a better criterion would be, if a language feature potentially breaks the abstraction of a high-level type-safe programming language. Then, it is clear that ORD and CHR are on the safe side, because we can always rely on getting a valid character code from ORD and being able to convert it back to the original character with CHR. But we can not rely on SYSTEM.VAL(INTEGER,setval) to give us an integer value which can be converted back to a valid set value with SYSTEM.VAL(SET,integerval), because sets may be implemented in a way incompatible with integer values. Richard
You are all solving the WRONG problem; except:Diego Sardina wrote:
My idea in general is to avoid any change to the language, especially those constructs that demonstrated to create problems in maintainability. Why don't enhance IDE capabilities?
Yes, didn't AOS start enhancing the IDE with syntax-coloring? I've evolved strong feeling on this topic, and would like to relocate the <swiss-author> who formally wrote about HumanComputerInterfacing. Appeciate that Oberon "comes from PARC" [as does wily below]. Here are your problem descriptions:-
restrict the typing overhead to the minimum under the current syntax. ... I wouldn’t use aliases just to save typing.
...interfering with the readability. ? HOW ? Don't confuse arty/looks-cool with readability.
"Oberon is a language and an *OS* ...". 2 separate aspects ! Compare our <baby style syntax>: C := SYSTEM.VAL(Connection, ConnTab[i]); a function Named:VAL in Module:SYSTEM which takes 2 args .... with eg. <shell>: find /PATH/File -name "*key*" >> C also has 2 InputArgs, but needs EXPENSIVE familiarisation to use. Or even worse Haskell: (>>=) :: Monad m => m a -> (a -> m b) -> m b Reading the documentation proves that the laguage/s is determined by the designers' subjective FEEL. I can't know if/that: the need to look/search between screen & keybrd, the 2-hands need to input eg. F-keys, the non-standard Laptop vs 101kybrds, etc. FEELS bad to you, as it does to me -- and error prone; because users [other than HCI specialists] don't want to analyse and discuss their subjective feelings. Eg. since I like to save typed-in-text very frequently: both for ETHO & wily, removing the need to reach for the mouse for the trivial/repeated <Store> by eg. <F2 = Store previously stored frame> would reduce the error prone work load. But don't mess with the language syntax. ----------- IMO wily is an even superior 90s-PARC inspired IDE (but lacking ETHO's color/font versatility) :- Stepping through an example session might best illustrate this: Susan has fetched the file frob.tar.Z. She clicks with B1 in the file name, and with B2 in the word untarz. The utility untarz uncompresses and untars the file, verbosely printing file names as it goes. She clicks with B3 on one of the file names, INSTALL, which opens the file. The INSTALL file suggests that she run configure then make. She clicks B2 in each of these words to run the suggested programs, but there's a problem. The make fails when gcc quits with the error message keyboard.c:4: strings.h: No such file or directory. She clicks with B3 in the first part of the error message, which opens the file and selects the line. On Susan's system there is a string.h but no strings.h. She removes the last s with a B1-B2 chord. When she modifies the file, Wily sets the ``file modified'' indicator, and adds the word ``Save'' to the tag for this window. Susan clicks B2 on the word Save to write the file, clicks B2 on make again, and she's done. This whole process uses about ten mouse clicks and no typing. ... For comparison, below are the sizes of three stripped, dynamically linked executables on the author's sun4d Solaris system: 167264 wily 234272 vi 1873336 xemacs PS. I've got wily's simple patch, to reverse the <mouse frame-scrolling-direction> to match ETHO's. ==crg
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Richard Hable Sent: Tuesday, 13 November 2018 6:18 AM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] SYSTEM Modules
Then, it is clear that ORD and CHR are on the safe side, because we can always rely on getting a valid character code from ORD and being able to convert it back to the original character with CHR.
But we can not rely on SYSTEM.VAL(INTEGER,setval) to give us an integer value which can be converted back to a valid set value with SYSTEM.VAL(SET,integerval), because sets may be implemented in a way incompatible with integer values.
ORD is not always on the safe side. The same argument applies to ORD(setval) as SYSTEM.VAL(INTEGER, setval) does it not? Chris.
On 15.11.18 11:45, Chris Burrows wrote:
ORD is not always on the safe side. The same argument applies to ORD(setval) as SYSTEM.VAL(INTEGER, setval) does it not?
I picked a bad example. In my (old) language report ORD was only appliable to CHAR, but in Oberon 07 it also supports SET and BOOLEAN. Thus, the language is now committed to a set implementation which allows safe conversion between SET and INTEGER values. For better or worse... On the other hand, no such guarantee is made for most other conversions possible with SYSTEM.VAL—let's say SYSTEM.VAL(BOOLEAN, setval). Richard
Consequently I’m thinking of implementing an extension to the Astrobe Oberon-07 compilers. This will allow low-level modules to be specified by prefixing the keyword MODULE with the keyword SYSTEM (similarly to the DEFINITION and IMPLEMENTATION module prefixes in Modula-2). Such system modules would allow / require any SYSTEM objects to be referenced unqualified.
It's more similar to what Modula-3 adopted for this. Modules that are going to use unsafe procedures/functions must place UNSAFE before the keyword MODULE or INTERFACE.
Any comments?
In my opinion it's a good solution.
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Diego Sardina Sent: Sunday, 11 November 2018 1:42 AM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] SYSTEM Modules
Consequently I m thinking of implementing an extension to the
Astrobe Oberon-07 compilers. This will allow low-level modules to be specified by prefixing the keyword MODULE with the keyword SYSTEM (similarly to the DEFINITION and IMPLEMENTATION module prefixes in Modula-2). Such system modules would allow / require any SYSTEM objects to be referenced unqualified.
It's more similar to what Modula-3 adopted for this. Modules that are going to use unsafe procedures/functions must place UNSAFE before the keyword MODULE or INTERFACE.
Thanks for the pointer. I'll have a closer look at what they did. The UNSAFE concept opens up a whole different set of opportunities / can of worms (depending on whether you are a glass half full / half empty sort of person). An UNSAFE module could allow: 1. Relaxed type-checking 2. Relaxed array bounds-checking 3. Variable parameter lists etc. All of which can be very useful for low-level / high-performance realtime code. The downside of any of these extended 'features' is that are frequently misused. e.g. I have seen cases where somebody has declared every procedure as FORWARD so they don't have to worry about the order of declaration! Some reasonable restrictions could be established to minimise this risk without impacting their usefulness. E.g. UNSAFE modules cannot import other modules; procedures in UNSAFE modules can only be leaf procedures etc. Regards, Chris Burrows CFB Software http://www.astrobe.com
Chris Burrows wrote:
(...) Consequently I’m thinking of implementing an extension to the Astrobe Oberon-07 compilers. This will allow low-level modules to be specified by prefixing the keyword MODULE with the keyword SYSTEM (similarly to the DEFINITION and IMPLEMENTATION module prefixes in Modula-2). Such system modules would allow / require any SYSTEM objects to be referenced unqualified.
(...) Any comments?
Any other suggestions for solving this problem?
The Modula-2 way of using: FROM SYSTEM IMPORT PUT, GET, BIT, UBF; has the advantage of self-documentation. If you would extend the Astrobe Oberon-07 compilers with SYSTEM MODULE ... maybe it would be sensible to advise programmers to always add a comment to document which procedures are imported from module SYSTEM, like this: SYSTEM MODULE Clock; IMPORT MCU; (* From SYSTEM imported: PUT, GET, BIT, UBF *) ... Hans --
Ha Hans, at hackerspace Techinc your Modula-2 project has a legendary status. As I was making my way through some cpp code written for the an esp8266 based I stumbled on the infamous yield() function. No one in the Space could explain what exactly was happening in the program when using this instruction. The message was that it was a trivial question. Just sprinkle some yields{} around the code and the wifi subsystem was kept alive. I refered to the one loop multi-task loop of the Oberon System. And from that I told that golang descended from Oberon and before that Modula. "Hey Modula-2, that is the same weird language that guy uses for his home beer brewery. On an Amiga. A real scientist. Everything must be exactly measured after the comma." For them, total representatives of the trial and error programming style, writing in Modula-2 was something as archaic as writing cuneiform. So, I'm interested in meeting you. It would be nice to see a working a realtime Writhian system in the flesh. Greets, F.P. Hans Klaver schreef op 2018-11-10 17:19:
Chris Burrows wrote:
(...) Consequently I’m thinking of implementing an extension to the Astrobe Oberon-07 compilers. This will allow low-level modules to be specified by prefixing the keyword MODULE with the keyword SYSTEM (similarly to the DEFINITION and IMPLEMENTATION module prefixes in Modula-2). Such system modules would allow / require any SYSTEM objects to be referenced unqualified.
(...) Any comments?
Any other suggestions for solving this problem?
The Modula-2 way of using: FROM SYSTEM IMPORT PUT, GET, BIT, UBF; has the advantage of self-documentation.
If you would extend the Astrobe Oberon-07 compilers with SYSTEM MODULE ... maybe it would be sensible to advise programmers to always add a comment to document which procedures are imported from module SYSTEM, like this:
SYSTEM MODULE Clock;
IMPORT MCU; (* From SYSTEM imported: PUT, GET, BIT, UBF *)
...
Hans
-- -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Chris: your Astrobe editor shows the word SYSTEM in bright red and I actually like it. I thought it was the step in the right direction to clearly point out the low level calls. From the perspective of being an occasional user (students use it more than I do) I would vote for keeping it the current way. Wojtek
participants (9)
-
Chris Burrows -
Diego Sardina -
eas lab -
Frans-Pieter Vonck -
Hans Klaver -
Jörg Straube -
Paul Reed -
Richard Hable -
Skulski, Wojciech