Where is I++ in VB.Net? 
Author Message
 Where is I++ in VB.Net?

I think we're all whining about 1 measly character difference, which can
occasionally result in a few more characters being saved when used in a
compounded (and, it seems, contraversial) way. It's not there, and I don't
think it needs to be. Well, at least, I'm quite happy without it.

P


Quote:



> > > It gives more then that when used inside longer statements:
> > >    a(i++)=b(j++)

> > Okay, better explanation: it gives a 1 character advantage per time
used.
> > But then, I presume that's what Jonathan meant originally, since it'd be
> > quite difficult for a piece of syntax to offer a one character advantage
> one
> > time it was used, and not the next, when you compare it to another piece
> of
> > syntax, assuming you don't change either along the way.

> When used in more complex expression it eliminates one or more statements
> and that ends up being more than a single character per use.  However you
> look at it, I find it  useful feature and C and would definitely make use
of
> it in VB if it were available.  I'd like to see it added.



Mon, 15 Sep 2003 18:39:32 GMT  
 Where is I++ in VB.Net?
Hmm, I remember you demonstrated this in a thread a while back. I'm not
gonna be the one to start this - last time the thread had about 20-30
postings... ;-)

P


Quote:
> > All that means is that both the syntax and semantics need to be defined
> for
> > the VB.Net implementation.

> Ok, lets play. Show me sequentially what this line does. Then we will take
a
> look at the possible problems.

> >    a(i++)=b(j++)

> --
> Jonathan Allen



Mon, 15 Sep 2003 18:40:59 GMT  
 Where is I++ in VB.Net?
I think a(i++)=b(j++) results in a double post. I'm just not sure
whether it's caused by the left side or the right side. ;)


Quote:
> > All that means is that both the syntax and semantics need to be
defined
> for
> > the VB.Net implementation.

> Ok, lets play. Show me sequentially what this line does. Then we will
take a
> look at the possible problems.

> >    a(i++)=b(j++)

> --
> Jonathan Allen



Mon, 15 Sep 2003 21:34:59 GMT  
 Where is I++ in VB.Net?


Quote:



> > > All that means is that both the syntax and semantics need to be
defined
> > for
> > > the VB.Net implementation.

> > Ok, lets play. Show me sequentially what this line does. Then we will
take
> a
> > look at the possible problems.

> > >    a(i++)=b(j++)

> j=j+1 ' rhs is evaluated first
> i=i+1
> a(i)=b(j)

Just to clarify...  that is how I would expect the compiled version to
execute.  If a different order was used that's fine provided that it is
defined so that it is possible to determine by reading the code what
happens.

BTW, this is not an important feature to me in the larger scheme of things.
I'd much rather see some of the VB6 syntax put back into the language than
more new syntax be added.  It just seems odd to me that the += style was
added but these operators were not.  If the prefix/postfix operators are
added then I'd use them and if the compiler doesn't limit abuse of them my
own coding standards will.



Mon, 15 Sep 2003 22:51:33 GMT  
 Where is I++ in VB.Net?


Quote:
> > Being able to abuse a feature isn't, imo, sufficient reason to eliminate
> it.
> > Most things can be abused but used judiciously they have value

> To some (or at least me), using it inside an expression is considered
> abusive. Using any destructive operation inside another expression is
> questionable in my book.

> Anyways, you still haven't answered...

> > > foo(++x, x++, ++x, x++) '

> If you cannot simply look at it and get a good idea of what is happening,
> then it violates another guiding philosophy of Basic programming.

I agree that that line is poor programming style.  I did mention that I
would consider it reasonable for the compiler to disallow any statement that
uses prefix or postfix notation on a single variable more than once in a
single line.  I'm sure other rules could be implemented as well.

All I am saying is that the syntax can be a handy shortcut and that it does
not have to be used badly.  Are you saying that anything that can be abused
should be removed from the language?



Mon, 15 Sep 2003 22:43:23 GMT  
 Where is I++ in VB.Net?


Quote:
> Ok, lets play. Show me sequentially what this line does. Then we will take a
> look at the possible problems.

> >    a(i++)=b(j++)

a(i)=b(j)
i = i+1 ' or i += 1
j = j+1 ' or j += 1

What can get {*filter*} (in terms of BASIC) is something like:

x = 5
dosomething(x++)

sub dosomething(byref b)
   b = b + 2
end sub

Does the compiler pass 5 to dosomething()... And when does the "++" get
processed?  After the sub is called, but before it returns -- or right
after it returns?  That's where you can get some ambiguity.

--
Patrick Steele

Lead Software Architect
Image Process Design



Mon, 15 Sep 2003 22:47:35 GMT  
 Where is I++ in VB.Net?


Quote:
> > All that means is that both the syntax and semantics need to be defined
> for
> > the VB.Net implementation.

> Ok, lets play. Show me sequentially what this line does. Then we will take
a
> look at the possible problems.

> >    a(i++)=b(j++)

j=j+1 ' rhs is evaluated first
i=i+1
a(i)=b(j)


Mon, 15 Sep 2003 22:40:37 GMT  
 Where is I++ in VB.Net?


Quote:
> > Ok, lets play. Show me sequentially what this line does. Then we will take
> a
> > look at the possible problems.

> > >    a(i++)=b(j++)

> j=j+1 ' rhs is evaluated first
> i=i+1
> a(i)=b(j)

What?  That's not the way I remember it from my C days.  Not that I'm
saying it's wrong -- but I don't think C# (not C/C++) do it that way.

With the prefix ++ (i.e. "++i"), the variable is incremented first and
then it's value is used.  With the postfix (i.e. "i++"), the variables'
value is obtained (and subsequently used/passed) and then it is
incremented.

--
Patrick Steele

Lead Software Architect
Image Process Design



Mon, 15 Sep 2003 22:55:37 GMT  
 Where is I++ in VB.Net?
Er, no...
given a(i++) = b(j++):
a(i) = b(j)
j = j + 1
i = i + 1

whereas a(++i) = b(++j)
j = j + 1
i = i + 1
a(i) = b(j)


Quote:



> > > All that means is that both the syntax and semantics need to be
defined
> > for
> > > the VB.Net implementation.

> > Ok, lets play. Show me sequentially what this line does. Then we will
take
> a
> > look at the possible problems.

> > >    a(i++)=b(j++)

> j=j+1 ' rhs is evaluated first
> i=i+1
> a(i)=b(j)



Mon, 15 Sep 2003 23:08:34 GMT  
 Where is I++ in VB.Net?
Jonathan, I think Ed's proved your point about the ambiguity and general
confusion about this piece of syntax already. I say, "Keep it out of VB".

P


Quote:
> Er, no...
> given a(i++) = b(j++):
> a(i) = b(j)
> j = j + 1
> i = i + 1

> whereas a(++i) = b(++j)
> j = j + 1
> i = i + 1
> a(i) = b(j)





> > > > All that means is that both the syntax and semantics need to be
> defined
> > > for
> > > > the VB.Net implementation.

> > > Ok, lets play. Show me sequentially what this line does. Then we will
> take
> > a
> > > look at the possible problems.

> > > >    a(i++)=b(j++)

> > j=j+1 ' rhs is evaluated first
> > i=i+1
> > a(i)=b(j)



Tue, 16 Sep 2003 00:08:02 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 
 

 
Powered by phpBB® Forum Software