[M3devel] introducing VAR in more places?

Jay jayk123 at hotmail.com
Tue Feb 12 15:05:46 CET 2008


Agreed!
C++ vs. WITH, C++ wins by not indenting unnecessarily.
See that change I was fiddling with in Time.m3 for examle.
 
Hm. Can we get consensus on a language change? :)
 
BEGIN  VAR a := 1;
  IO.PutInt(a);
  VAR b := 2, (* ? *) 
         c := 3; (* ? *) 
  IO.PutInt(b);
 
? Easier to require "VAR" on each, a bit wordy.
 
 - Jay



> Date: Tue, 12 Feb 2008 08:52:05 -0500> From: hendrik at topoi.pooq.com> To: m3devel at elegosoft.com> Subject: Re: [M3devel] introducing VAR in more places?> > On Tue, Feb 12, 2008 at 05:41:31AM -0800, Mika Nystrom wrote:> > hendrik at topoi.pooq.com writes:> > >On Mon, Feb 11, 2008 at 10:17:13PM -0600, Rodney M. Bates wrote:> > >> I don't think this is what Tony meant. In C++, an opening brace> > >> starts a block, but every local declaration in that block has its own> > >> unique scope that only starts at that declaration and goes to the end> > >> of the block. This is particularly messy because the local declarations> > >> of a block need not all precede all the statements,> > >> > >That is, in my opinion, one of the few things that C and C++ did right, > > >well, almost right. It permits a coding style in which every > > >variable declaration is initialised, and is declared if and only if it > > > > You can do all kinds of fun stuff with C's declarations/initializations.> > > > switch (a) {> > int x=7;> > case 0:> > use(x); /* oops */> > ...> > }> > > > goto somewherefun;> > > > {> > int y=7;> > > > somewherefun:> > use(y); /* oops again */> > }> > That's more a problem with C's control structures. Each case should be > a block of its own. The bits outside any case shouldn't be there. > etc., etc.> > > > > > > >has a value. Now that's a useful property. It fails for recursion, > > >so there are limits in how far it can apply. And when coding like this, > > >you want the simplest syntax to define a constant identifier -- one > > >whose value cannot be rebound except by reexecuting the entire block. > > >Making something that can change should require more effort -- like > > >adding a keyword "var" or some such.> > > > Sounds to me like you're talking about Modula-3's WITH!> > Close, except for syntax. If you use WITH in the stype I'm > advocating you end up with extremely deep syntactic nesting, and you > indent off the side of the page. Also, the whole WITH syntax is quite > heavy.> > -- hendrik
_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080212/70f63d19/attachment-0002.html>


More information about the M3devel mailing list