473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Do operators work on a Point structure?

I am trying to add 2 points together, and I am not succeeding.
It appears the docs say I need a point and a size, but even that fails
in the copy of VS 2003 I have.

Exactly what are they trying to say here?

http://msdn.microsoft.com/library/de...itionTopic.asp

Can't I use: pt1 = pt2 + pt3

Or do I need a size: pt1 = pt2 + sz3

The only thing that compiles, is as shown:

pt1 = Point.op_Addition(pt2, sz3)

But that doesn't show in Intellisense, what's going on?

LFS
Nov 20 '05 #1
6 1268
Larry,
Neither VB.NET 2002 nor VB.NET 2003 support overloaded operators. VB.NET
2005 (Whidbey) will however support using & defining overloaded operators!
So for now you will need to explicitly call the operators, as you showed.
pt1 = Point.op_Addition(pt2, sz3)
But that doesn't show in Intellisense, what's going on? You need to turn off the "Hide advanced members" under "Tools - Options -
Text Editor - Basic - General"
Hope this helps
Jay

"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl... I am trying to add 2 points together, and I am not succeeding.
It appears the docs say I need a point and a size, but even that fails
in the copy of VS 2003 I have.

Exactly what are they trying to say here?

http://msdn.microsoft.com/library/de...itionTopic.asp
Can't I use: pt1 = pt2 + pt3

Or do I need a size: pt1 = pt2 + sz3

The only thing that compiles, is as shown:

pt1 = Point.op_Addition(pt2, sz3)

But that doesn't show in Intellisense, what's going on?

LFS

Nov 20 '05 #2

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote
Larry,
Neither VB.NET 2002 nor VB.NET 2003 support overloaded operators. VB.NET
2005 (Whidbey) will however support using & defining overloaded operators!


You would think they would say that, instead of:

" In Visual Basic, you can use the operators defined by a type, but you cannot define your own."

That is what is on the page, and it is misleading. The 'you can use' should not be on that page....

:-(
LFS
Nov 20 '05 #3
* "Larry Serflaten" <se*******@usinternet.com> scripsit:
Neither VB.NET 2002 nor VB.NET 2003 support overloaded operators. VB.NET
2005 (Whidbey) will however support using & defining overloaded operators!


You would think they would say that, instead of:

" In Visual Basic, you can use the operators defined by a type, but you cannot define your own."

That is what is on the page, and it is misleading. The 'you can use' should not be on that page....


Mhm... An operator is only a special procedure, and you can call this
procedure from VB.NET ;-). If a language's addition operator is not
'+', and instead it's 'ADD', then documentation will be misleading
too...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Larry,
The "you can use" means you can call the sub directly as you have found, I
agree it is misleading, as it does not support using the operator itself.

Hope this helps
Jay

"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:OW*************@TK2MSFTNGP10.phx.gbl...

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote
Larry,
Neither VB.NET 2002 nor VB.NET 2003 support overloaded operators. VB.NET
2005 (Whidbey) will however support using & defining overloaded
operators!
You would think they would say that, instead of:

" In Visual Basic, you can use the operators defined by a type, but you cannot define your own."
That is what is on the page, and it is misleading. The 'you can use' should not be on that page....
:-(
LFS

Nov 20 '05 #5

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote
" In Visual Basic, you can use the operators defined by a type, but you cannot define your own."

That is what is on the page, and it is misleading. The 'you can use' should not be on that page....
Mhm... An operator is only a special procedure, and you can call this
procedure from VB.NET ;-).


Where do you get that?

//000048: A = 1
IL_0001: ldc.i8 0x1
IL_000a: stloc.0
//000049: B = 2
IL_000b: ldc.i8 0x2
IL_0014: stloc.1
//000050: C = A + B
IL_0015: ldloc.0
IL_0016: ldloc.1
IL_0017: add.ovf
IL_0018: stloc.2

Add.ovf is not a special procedure of any given data type.
If we were talking about a reference type, then of course, it has
to a procedure, but we're not, we are talking about a value type
so I would think any defined operators would be candidates
for inlining the code....

If a language's addition operator is not
'+', and instead it's 'ADD', then documentation will be misleading
too...

I was looking at the "Point Addition Operator" Page, that indicates
that such an operation is possible using the 'operator' as would be
expected. The text goes on to say 'you can use' regaurdless of
whatever else it says. I would (and did) suggest that it should not
use those words, that it should say something more like:

"The Point addition operator is not supported in Visual Basic."

It could also add, what you said, "To add two points together,
call the op_Addition method from your code.

How does their generic remark help the user? (its the same remark
as the other common operators) It is actually a source of
confusion when the remarks say 'you can use' but the reality
is that you cannot.

I already suggested they change the wording, so I am moving on,
no reply is necessary.... :-)

LFS
Nov 20 '05 #6
Larry,
Add.ovf is not a special procedure of any given data type.
If we were talking about a reference type, then of course, it has
to a procedure, but we're not, we are talking about a value type
so I would think any defined operators would be candidates
for inlining the code.... Your leaving out one minor point. Int32 (Integer) is a "native" IL value
type, in that there are specific IL instructions for Integers. Where as
Point is simply a value type.

If you look at System.Int32 you will not find an op_Add, where as on
System.Drawing.Point, there is an op_Add.

The compiler has to treat Integer differently then it does Point (the
difference being having specific IL instructions, not whether its a value
type or a reference type). Adding support for overloading operators (the
op_Add routines) is above & beyond what is needed for the "native" IL value
& reference types. (Reference types such as Array & String). I hope you
agree if the compiler did not support the "native" IL types, you would have
an extremely limited compiler ;-)

Hope this helps
Jay
"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote
" In Visual Basic, you can use the operators defined by a type, but you cannot define your own."
That is what is on the page, and it is misleading. The 'you can use'
should not be on that page....
Mhm... An operator is only a special procedure, and you can call this
procedure from VB.NET ;-).


Where do you get that?

//000048: A = 1
IL_0001: ldc.i8 0x1
IL_000a: stloc.0
//000049: B = 2
IL_000b: ldc.i8 0x2
IL_0014: stloc.1
//000050: C = A + B
IL_0015: ldloc.0
IL_0016: ldloc.1
IL_0017: add.ovf
IL_0018: stloc.2

Add.ovf is not a special procedure of any given data type.
If we were talking about a reference type, then of course, it has
to a procedure, but we're not, we are talking about a value type
so I would think any defined operators would be candidates
for inlining the code....

If a language's addition operator is not
'+', and instead it's 'ADD', then documentation will be misleading
too...

I was looking at the "Point Addition Operator" Page, that indicates
that such an operation is possible using the 'operator' as would be
expected. The text goes on to say 'you can use' regaurdless of
whatever else it says. I would (and did) suggest that it should not
use those words, that it should say something more like:

"The Point addition operator is not supported in Visual Basic."

It could also add, what you said, "To add two points together,
call the op_Addition method from your code.

How does their generic remark help the user? (its the same remark
as the other common operators) It is actually a source of
confusion when the remarks say 'you can use' but the reality
is that you cannot.

I already suggested they change the wording, so I am moving on,
no reply is necessary.... :-)

LFS

Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: greg | last post by:
Discussion is invited on the following proto-PEP. ------------------------------------------------------------- PEP ??? - Overloadable Boolean Operators...
1
by: bberu | last post by:
> Ivan Vecerina and Swampmonster wrote: > > bberu wrote: > >> I know it is possible to refine operators (like +, -, * or /) on classes. > >> But is it possible on simple types ? > >> ex : >...
14
by: Jinesh | last post by:
Dear Guru's: Have a simple C questions. Is this a bug or am I doing something reallllly stupid? Here's the code snippet:- ---------------------------Code------------------------------...
10
by: Edward Diener | last post by:
The documentation states the names of the various managed operators but does not give the signature for them. Is there some documentation which I have missed that gives the correct signature ? In...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
52
by: spibou | last post by:
This concerns the Wikipedia article on C and C++ operators: http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B Until very recently the first table in the page was a very useful one on the...
16
by: Santosh Nayak | last post by:
Hi, Is there any way to catch the losing bit occurring due to Right Shift Operator ? e.g int a = 5 ; a = a >1 ; // // a is now 2 and the least significant bit is lost // // I want this...
28
by: dspfun | last post by:
I'm trying to get a good understanding of how unary operators work and have some questions about the following test snippets. int *p; ~!&*++p--; It doesn't compile, why? The problem seems to be...
6
by: JohnQ | last post by:
I like, non-copyable, non-assignable and, most often, non-default-constructable also, as a starting point for class design: class SomeClass { SomeClass(); // disallow default construction...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.