[M3devel] Enumeration or subrange value out of range

Hendrik Boom hendrik at topoi.pooq.com
Tue Nov 30 16:04:18 CET 2010


On Tue, Nov 30, 2010 at 10:19:37AM +0100, Dragiša Durić wrote:
> 
> On Nov 30, 2010, at 9:32 AM, Jay K wrote:
> 
> > It is true they were terrible for a long time.
> > Don't Modula-3 generics have the same problem?
> > At least in the C++ case:
> >   - the errors aren't in generated files 
> 
> They are generated, but they are exact source you would "generate" for 
> it. Aren't they? And you have them to step through with debugger. At 
> least, I never hit a wall with them, like I did with that .h for 
> vectors.

And you know what files they were gerenated from, and with what 
parameters.

> 
> >   - you don't have to explicitly instantiate everything "in the build system"
> 
> That would be a killing experience, to add even more complexity to 
> Makefiles :).

C++ managed to make linkers the world over vastly more ocmplex.  It's 
the linker that discovers that some templates haven't been compiled yet 
and calls the compiler to compile them.  I really don't think linkers 
should be all *that* language-dependent.

> 
> >   - for function templates, you never have to instantiate anything
> >  The automatic deduction of function template parameters is very powerful.
> >  You have to try it.

Is finding the right template to instantiate with the right 
parameters always unambiguous?

> >  I *believe* it enables a style of programming similar to ML, esp. when combined with the more recent
> >  feature "auto".
> 
> A style is something I'd happily trade for discipline. I like to find my place in 10 year old project in minutes, and I like to not think about releases and subreleases of language spec (!??!!?) happening during a lifetime of my project.

I don't mind ML's style, except that programmers tend to leave out too 
many explicit types for readability.  I do mind, in C++, having 
something "similar to" ML without ML's internal discipline.

> 
> > It is also true that templates seem to be largely accidental in what they allow.
> > It seems they were designed with two primary applications:
> >   std::vector
> >   std::min/max
> 
> There's folk saying here, it goes like: "To kill an ox for a kilo of meat."

That's the standard practice in C++.  To introduce complicated 
mechanisms tso that the programmer, with sufficient effort, can mimic 
features that should better have been reliably built into the language 
in the first place.

> 
> What you can do with these, and what you need to be done with these... 
> It is mostly scope of some more dynamic environment, scripting comes 
> to mind. To put them in compiled environment is just more of C++'s 
> featurism (we can do it, why don't we...)... Your comparison to ML is 
> right on spot. 

Except that ML is more rationally and consistently typed.

>C++ is just mixed philosophy, mixed styles, mixed 
> everything. Mixed results just follow suite.
> 

-- hendrik




More information about the M3devel mailing list