gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] Returning a string constant


From: Iztok Kobal
Subject: Re: [Gm2] Returning a string constant
Date: Thu, 30 Oct 2008 08:59:40 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.17) Gecko/20080922 SUSE/1.1.12-1.1 SeaMonkey/1.1.12

Both Gaius and Andreas are right when they say their arguments about why
open arrays and similar C gadgets are dangerous, time consuming at
compile time etc etc.
As far as I see, the main reason is that at the time of the modula-2
specification we already had another language which was unsafe enough
that programming errors caused by its misuses are still there both in
unices and windows. There was simply no room for another unsafe
language. Another reason was that modula-2 was meant to be productively
used in embedded programming opposed to pascal as schooling language. In
fact, ABB has written firmware for its ProMaster industrial controllers
series in modula-2 and Westinghouse has used modula-2 for the most
critical parts of control systems for nuclear plants, to mention just
two of greatest modula-2 users. The word 'embedded' meant two things at
that time - language should have helped programers to not make stupid
mistakes and its compiler had to be effective.

Proof ?

OK - back in 1989 we have made the software on top of untested new
hardware for 8/bit multiprocessor platform for Remote Terminal Units in
electrical distribution and transmission substation in only 3 months,
all testing and documenting included ! I can not recall how many lines
were there - I suppose as much as 200000+ and we were 4 programmers, me
newcomer. My experience was - wow ! I compile something, put into EPROM,
switch the power on and it does not crash ! From the scratch, my
friends, from the simple Hello world program on. Thank you professor
Wirth for modula-2 ! Imagine development cycle for such application in C
and all stupid open arrays mistakes, not mentioning casting errors etc
etc etc. My experience was - with modula-2 I have used 60% time writing
code and thinking about what to implement, while with C/C++ 90% of time
is used for debugging and thinking how to implement the content. 10% vs.
60% of the effect - the difference is obvious !

And another - we made excellent protocol conversion gateway for the
station communication controller purposes, again for electrical
transmission and distribution plants, running as many as 20 different
communication lines over as many as 15 differemt communication protocols
on single CPU. We have used DOS+RTX, Windows and Linux for running this
application. Again, there were 200000 lines of ISO modula-2 code, add or
take some. Recently we have rewritten (not added anything, rather
removed) the application in C++. The difference in compile time was
killing : Both Gardens Point and Stony Brook M2 did their jobs,
compiling and linking, under 10 seconds on 150MHz pentiums, GCC's c++
takes about 5 minutes on 3GHz dual cores !

So, Gaius - please, keep GM2 clean, mean and lean, strictly inside
standards, and thus allow modula-2 another chance in programming world.
Its simplicity and safety should show that its use pays off !

Regards !

Iztok

Breeden, Thomas (tmb) wrote:
> Gaius, et. al.,
>
> Neat. I had thought you had implemented structured type returns.
>
> I plan to avoid them like the plague :)
> Though, if they discourage anyone from writing string functions that
> return POINTER TO CHAR or something like that resembling that
> "C" practice, they have done a good thing.
>
> BTW, one thing that has puzzled me about the ISO Standard is that it
> states "No direct assignments to open array formal parameters may be
> made" - no ifs, ands, or buts.
>
> So the, when s is an open array parameter, the
>   s := "test";
> alternative to
>   Assign("test",s);
> should be illegal in an ISO conforming compile mode
> but I am not sure why.
>
> So far as I can see, either way, if HIGH() is accurate it should be safe,
> and if not, unsafe.
>
> Tom
> address@hidden
>
>   
>> -----Original Message-----
>> From: Gaius Mulley [mailto:address@hidden
>> Sent: October 27, 2008 4:52 PM
>> To: Breeden, Thomas (tmb)
>> Cc: address@hidden
>> Subject: Re: [Gm2] Returning a string constant
>>
>> "Breeden, Thomas (tmb)" <address@hidden> writes:
>>
>>     
>>> Hi all,
>>>
>>> Actually, in ISO Standard Modula-2, it is legal.
>>> ...
>>>       
>
>   
>> Hi,
>>
>> now fixed in the CVS.  GNU Modula-2 allows formal parameters to be
>> specified as:
>>
>> FormalParameters := '(' [ MultiFPSection  ] ')' [ ':' Qualident  ]
>>                   =:
>>
>> which is (after the ":") the same as PIM2 p148 line 80,
>> PIM3 p172 line 76, PIM4 p158 line 80 and ISO p641 C.2.4.2.
>>
>> Many thanks for the bug report - it did work if a temporary
>> variable was used, such as:
>>
>> PROCEDURE test () : string ;
>> VAR
>>    t: string ;
>> BEGIN
>>    t := "test" ;
>>    RETURN t
>> END test ;
>>
>> but it should have worked without the need for this temporary..
>>
>> regards,
>> Gaius
>>     
>
>
> _______________________________________________
> gm2 mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/gm2
>
>   





reply via email to

[Prev in Thread] Current Thread [Next in Thread]