[M3devel] saving indentation?

Dragiša Durić dragisha at m3w.org
Sat Sep 1 23:18:13 CEST 2012


It is only normal to have such an attitude when coming from "save typing" language/world/mindset. If nothing else, C is economic. :)

Correct me if I am wrong but - continue is hidden goto. When you are attuned to it, it's nice and cozy. When you are not, you look around a lot, scratching your head. break, continue, goto… Just recently a friend explained to me how goto is totally legitimate way to handle exit from a procedure - and he said it is sooo readable…. So is break and continue, when you are in a right groove. I don't think I am :).

Variable declaration everywhere (it reminded me of Javascript for a moment, and I had chills :) - it looks nice but it is obviously not great rogramming style. C9x probably has some solution to "name already defined in this same scope" and similar, but it looks clumsy in any case.

I try not to overuse WITH. From time to time I find local variables or extra block much more readable. Of course, in your case you'll  sacrifice C9x economy - variable setting is not its initialization. But, You'll save some horizontal space and skip few WITH's.

As for horizontal space… You are not kidding here? Or you have some reason to not like widescreen laptops? If there is one thing my macbook  has in abundance - it is horizontal space.

Of course, I am totally on the other side of programming language spectre. My background is Modula-2 (25 yrs) and Modula-3 (cca 15yrs). Everything else is secondary to these two. So, I am probably missing a lot of C9x viewpoint issues.

On Sep 1, 2012, at 10:28 PM, Jay K wrote:

> I would LIKE to write it like so:
> 
> 
>         var-or-const name := M3ID.ToText(proc.name);
>         var-or-const length := Text.Length(name);
>         FOR i := FIRST(u.handler_name_prefixes) TO LAST(u.handler_name_prefixes) DO
>             var-or-const prefix := u.handler_name_prefixes[i];
>             var-or-const prefix_length := Text.Length(prefix);
>             IF length <= prefix_length OR NOT TextUtils.StartsWith(name, prefix) THEN
>                 continue;
>             END;
>             var-or-const end = Text.Sub(name, prefix_length);
>             FOR i := 0 TO Text.Length(end) - 1 DO
>                 IF NOT Text.GetChar(end, i) IN ASCII.Digits THEN
>                     RETURN FALSE;
>                 END;
>             END;
>             RETURN TRUE;
>         END;
>         RETURN FALSE;
> 
> 
> but Modula-3 doesn't have "continue", right, and var/with imply indentation,
> So I have to write:
>         WITH    name = M3ID.ToText(proc.name),
>                 length = Text.Length(name) DO
>             FOR i := FIRST(u.handler_name_prefixes) TO LAST(u.handler_name_prefixes) DO
>                 WITH    prefix = u.handler_name_prefixes[i],
>                         prefix_length = Text.Length(prefix) DO
>                     IF length > prefix_length AND TextUtils.StartsWith(name, prefix) THEN
>                         WITH end = Text.Sub(name, prefix_length) DO
>                             FOR i := 0 TO Text.Length(end) - 1 DO
>                                 IF NOT Text.GetChar(end, i) IN ASCII.Digits THEN
>                                     RETURN FALSE;
>                                 END;
>                             END;
>                             RETURN TRUE;
>                         END;
>                     END;
>                 END;
>             END;
>         END;
>         RETURN FALSE;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120901/88309b75/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120901/88309b75/attachment-0002.sig>


More information about the M3devel mailing list