[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Modula-2 generics, exceptions, and optional parameters - how widely
From: |
Gaius Mulley |
Subject: |
Re: Modula-2 generics, exceptions, and optional parameters - how widely supported? |
Date: |
Thu, 28 Mar 2024 11:08:30 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Benjamin Kowarsch <trijezdci@gmail.com> writes:
> On Thu, 28 Mar 2024 at 05:52, Alice Osako wrote:
>
> I know that ISO Modula-2 added both exceptions and optionally, generics.
>
> Exceptions are part of the ISO M2 base standard while generics are an
> additional standard on top of the base standard.
exceptions are fully supported in gm2 (also note there is SYSTEM.THROW
as well).
> Further, I know that GNU Modula-2 also supports optional parameters and
> optional return values, but as far as I can tell those are unique to
> GM2.
>
> Yes, those are GM2 extensions, not available elsewhere.
>
>
> I think you will find that template expansion by placeholder replacement is
> VASTLY SUPERIOR to any static generics facility in any language. And once you
> have worked on this basis, you will never ever want to go back to anything
> that is built into or bolted onto the language.
>
> Any static generics facility built into a language is nothing else but text
> replacement anyway. It doesn't do anything different. However, it hides what
> it does
> from you. You are blind. You cannot see what it has generated. You may think
> you know what the actual source code is that the compiler is translating, but
> it
> may be something quite different and you won't know. And this poses a very
> serious problem when debugging.
>
> With a template expansion utility, you will see what the compiler sees.
>
> And, you can inject text into comments, so that the expanded source code
> tells you what version it is.
>
> Thus, from a usability perspective alone, an external template expansion
> utility is already superior.
>
> Then, there is the aspect of implementation and complexity/reliability of the
> compiler. Why should the compiler be burdened with the task of expanding
> templates? Why should the compiler have to check the syntax of the template?
> The only thing that matters is whether the generated source is syntactically
> correct. The compiler doesn't need to care whether the template is correct.
> Furthermore, there is no need to expand a template over and over and over
> again,
> once it has been expanded.
>
> Keeping template expansion out of the compiler significantly reduces
> implementation complexity and thus reliability.
>
> And then you can always add features to the template engine utility for
> common use cases that make things easier. The compiler will not be impacted
> by that
> at all. The compiler always expects correct Modula-2 input and the job of the
> template and template expansion is to generate correct Modula-2.
>
> So, I'd recommend you try working with an external template expansion utility
> and then see how this works out.
I concur, as a side note it is possible to insert line directives into
the processed source to direct the debugger to the original source.
So for example:
# 123 topsource.mod
some mangled m2 code
when compiled with gm2 -g will contain debugging info relating "some
mangled m2 code" to line 123 in file topsource.mod. I find this feature
useful to toggle on/off depending the level of debugging required.
- Re: Unicode I/O for GM2, (continued)
- Re: Unicode I/O for GM2, Gaius Mulley, 2024/03/26
- Re: Unicode I/O for GM2, Benjamin Kowarsch, 2024/03/26
- Re: Unicode I/O for GM2, Gaius Mulley, 2024/03/26
- Re: Unicode I/O for GM2, Benjamin Kowarsch, 2024/03/26
- Re: Unicode I/O for GM2, Gaius Mulley, 2024/03/26
- Re: Unicode I/O for GM2, Alice Osako, 2024/03/26
- Re: Unicode I/O for GM2, Gaius Mulley, 2024/03/26
- M2Unit? (was Re: Unicode I/O for GM2), Alice Osako, 2024/03/27
- Modula-2 generics, exceptions, and optional parameters - how widely supported?, Alice Osako, 2024/03/27
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?, Benjamin Kowarsch, 2024/03/28
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?,
Gaius Mulley <=
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?, Benjamin Kowarsch, 2024/03/28
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?, Alice Osako, 2024/03/28
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?, Benjamin Kowarsch, 2024/03/28
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?, Alice Osako, 2024/03/28
- Re: Modula-2 generics, exceptions, and optional parameters - how widely supported?, Benjamin Kowarsch, 2024/03/28