[Oberon] Standalone BlackBox programs was: GUI programming inOberon.
Jörg Straube
joerg.straube at iaeth.ch
Thu Mar 31 07:21:44 CEST 2016
Lars
From time to time mathematicians use kind of typing as well :-)
Their variables or functions work either on N (integers), Q (rationals), R (reals) or Z (complex)
Further on, mathematicians tend to work with unlimited precision. Mathematicians have no problem to say the 1 millionth digit of pi is 5.
If we want to calculate that on a real computer you unfortunately have the hassle to deal with limited resources.
Mentioning limits: You are right, the "limit thing" is kind of inconsistent in Oberon. With basic types (BYTE, INTEGER, LONGIT, REAL...) you don’t mention a limit explicitly, although the compiler allocates a kind of implicit limit to the variables of this type - mainly the size of the register to hold the variable (8 bits, 16 bits, 32 bits…)
For structured types (eg ARRAY) you have to mention the limit as it is good practice protect your memory:
In my point of view the problem with variable sized (open) strings is: what should a compiler do with an expression like s[1000] := „a“.
Assume s has currently the length of 500 CHARs:
- shall it be extended to length 1000 or
- should it say "out of index“ or
- is there a typo as you wanted to write s[100] := „a".
Upfront declaration is a good thing as it is a kind of guard against typos. If you use in your code the variable „countr" but actually meant your variable „counter“, the compiler with implicit declaration would allocate a new variable instead of telling you "I don’t know what you want me to do".
br
Jörg
> Am 31.03.2016 um 06:19 schrieb Lars <noreply at z505.com>:
>
> On Wed, March 30, 2016 8:36 pm, Douglas G. Danforth wrote:
>> TYPE String = POINTER TO ARRAY OF CHAR;
>>
>>
>> That allows an arbitrary length string determined at run time.
>> VAR string: String;
>> NEW(string, 1000);
>>
>
> You are still defining a max of 1000. Just at run time.
>
> Now it is even worse, because your code is bloated up with the
> declarations (restrictions or constraints) as code, instead of it being a
> declaration at the top of your source. So instead of your program focusing
> on the problem at hand, your code is filled and riddled with string code.
> This was the problem with C language in the 1970's all the way up to today
> where people still use C for application development (I have no idea why).
>
> People riddle their code with string allocations instead of the
> application being filled with useful code that needs to be seen by
> developers. The application ends up being flooded with string allocations
> that should have all been automated, since 1995 or whenever Ansistring
> technology emerged (delphi 2.0?)
>
> But I've already discussed my issues with oberon many times regarding that.
>
> Arbitrary would be:
>
> s := NEW(string);
> s := "do whatever"
> s := s + " you want"
>
> But the question is, why even bother with the "NEW".
>
> In mathematics, do you go:
>
> X := NEW INTEGER(2)
> Y := NEW INTEGER(40)
> X + Y = 42
>
> In math you just go:
>
> X = 2
> Y = 40
> X + Y = 42
>
> There is no "NEW" all over your maths texts.
>
> That's another interesting issue: is mathematics strongly typed and
> statically typed? It seems like mathematicians use type inference when
> they write on the chalk board. Mathemeticians may say "X is a whole
> number" however they often skip this step and just say "X=6" without
> declaring it first. Interesting. Maybe that's why so many mathematicians
> use languages like python or mathematica instead of oberon.
>
> "Is there a need for the Mathematica language to be strongly typed like
> C++? No. It is used to generalise and automate tasks and for deeper
> problem understanding and solving."
>
> That's not my opinion, just a quote from a website.
> Should math be strongly statically typed?
> Should mathematicians have to declare their variables before talking about
> them further? Mathematics seems always about quick shortcuts and terse
> expressions, rather than verbose long form time consumers. I wonder if
> it's why a lot of mathematicians simply do not use oberon, and use
> dynamically typed languages instead.
>
>>
>> or you can do
>>
>> string := NewString ('Hello, world!');
>>
>> where
>>
>> PROCEDURE NewString (IN x: ARRAY OF CHAR);
>> VAR string: String;
>> BEGIN
>> NEW(string, 1+LEN(x));
>> string$ := x$ RETURN string
>> END NewString;
>>
>
> This should all be automated. No programmer should have to spend his time
> doing these sorts of things IMO. It's very similar to 1970 C programming
> where you had to allocate your pointers to chars. It's a little higher
> level than C and safer, but compared to using a delphi string back in
> 1990's over 20 years ago, are we this far behind in computing technology
> that we have to manually do this sort of thing just to work with a string?
>
> Imagine with integers you had to do this:
>
> NewInteger(i, 0, 500)
>
> Where 0 defines the minimum value of the integer, and 500 defines the max
> value it can be.
>
> A run time integer. But why? Imagine a mathematics text riddled with these
> declarations:
>
> NewInteger(x, 40)
> NewInteger(y, 2)
>
> Why would a mathematician want his maths text to be as verbose as this
> when he could simply go:
>
> x = 40
> x = 2
>
> And it is just as clear.
>
> Similarily:
>
> x + y = 42
>
> is much clearer than
>
> NewInteger(x, 40) + NewInteger(y, 2) = 42
>
> Less is more.
>
> s := "anything I want" + " this string to be"
>
> Compared to:
>
> s := Concat(NewString("anything I want"), NewString(" this string to be"));
>
> Horrible.
> --
> Oberon at lists.inf.ethz.ch <mailto:Oberon at lists.inf.ethz.ch> mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon <https://lists.inf.ethz.ch/mailman/listinfo/oberon>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20160331/824216d6/attachment-0001.html>
More information about the Oberon
mailing list