[Coco] C VS Basic Coco

Wayne Campbell asa.rand at gmail.com
Wed Feb 14 13:25:49 EST 2018


I intended to also add that variable names in Basic09 can be up to 29
characters in length. While this sounds great, it can actually be too much.
I find that between 8 and 15 characters is more than enough, and you can
include comments for greater clarity, such as:

(* Partial header for a Basic09 I-Code module
TYPE HEAD=sync,modSize:INTEGER \(* sync = sync bytes, modSize = module size
DIM header:HEAD

In one reply the writer stated that they didn't believe BASIC could be used
to write anything substantial. My I-Code "unpacker", decode, is written
entirely in Basic09. While I'm sure some parts could be better written
(smaller, more efficient) in assembly, I do not understand OS-9 assembly
(or assembly at all for the most part), so Basic09 is what I write in
because it is what I know. decode is not slow, nor is it cumbersome. The
code is easy enough to follow (I wish I could make it easier, as I'm not
sure I would still be able to follow it after a 10-year separation), and I
include comments... many comments... to help someone understand what it is
I am doing with the code. I have learned, after all the time I have spent
writing DCom (my original I-Code decompiler) and decode, that it really
takes a book to make it easy to follow someone's code (or even your own if
long enough away from it). You would have to explain every statement
(almost) for the reader to have any real clue what you were doing and why
you did it that way.

I have not written that book for decode, and because I didn't write it for
DCom I had to start over with decode. Object lesson is to try to give
yourself (or anyone else) enough explanation to follow your logic. If you
don't, you (or they) will have a hard time deciphering what you were doing.

Wayne


On Wed, Feb 14, 2018 at 9:42 AM, Wayne Campbell <asa.rand at gmail.com> wrote:

> I agree, Bill. There are times when GOTO is useful, but even then I try to
> finds an alternative before using it. The IF/THEN <line ref> in Basic09
> uses what the header to Basic09 calls the invisible GOTO. The token is $55.
> It is also used in other constructs as well, so there is use for GOTO even
> behind the scenes.
>
> Wayne
>
> On Wed, Feb 14, 2018 at 9:29 AM, William Astle <lost at l-w.ca> wrote:
>
>> On 2018-02-14 10:06 AM, Bill Gunshannon wrote:
>>
>>> Ask Dykstra.  Or just look at the decades of research into why GOTOs are
>>> bad.
>>> In one of my last professional programming gigs I took more than a dozen
>>> programs heavily laced with GOTOs (true spaghetti code!!) and using
>>> proper
>>> structured programming removed all of them.  While I am not one who
>>> heavily
>>> favors standards bodies I think when they decided to come up with a BASIC
>>> standard it should have deprecated the GOTO entirely.
>>>
>>
>> Unrestrained use of GOTO is definitely bad. Especially when you have
>> better alternative control structures (FOR, WHILE, etc.) and proper
>> blocking that hide underlying GOTO business.
>>
>> However, there are some cases where it can serve to make the code flow
>> clearer.
>>
>> Note that I'm not advocating for the use of GOTO everywhere. I'm simply
>> saying that getting rid of it entirely is a bit like throwing the baby out
>> with the bath water. Is it strictly required? No. Is it useful sometimes?
>> Yes.
>>
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>>
>
>
>
> --
> Wayne
>
> The Structure of I-Code
> http://www.cocopedia.com/wiki/index.php/The_Structure_of_I-Code
>
> decode
> http://cococoding.com/wayne/
>



-- 
Wayne

The Structure of I-Code
http://www.cocopedia.com/wiki/index.php/The_Structure_of_I-Code

decode
http://cococoding.com/wayne/


More information about the Coco mailing list