473,395 Members | 1,556 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,395 software developers and data experts.

FEATURE REQUEST: Property set via ref parameter

Hi,

It would be nice and a natural way to use a property set by permitting it
to be set via a REF parameter on a method call.

Why this isnt being allowed is beyond me, yes I know they are wrappers for
get_ and set_ methods but if they are there to give the impression of a
FIELD, then they should have all the functionality of a field and not some
half brained implementation.

Thanks.

Nov 15 '05 #1
13 3039
<di********@discussion.microsoft.com> wrote:
It would be nice and a natural way to use a property set by permitting it
to be set via a REF parameter on a method call.
I'm afraid I don't agree...
Why this isnt being allowed is beyond me, yes I know they are wrappers for
get_ and set_ methods but if they are there to give the impression of a
FIELD, then they should have all the functionality of a field and not some
half brained implementation.


No, because they're simply *not* fields. Passing a variable by
reference creates another variable with the same memory slot - that
just isn't how properties work. Developers should have a clear view
that properties are really methods in disguise rather than fields in
disguise.

Passing variables by reference should usually be avoided anyway, to be
honest - it's usually a sign of a method trying to do too much.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
They are giving the impression of fields, thats why we can do a
SomeObj.SomeProperty = someValue just like a field assignment, same for get
someVal = SomeObj.SomeProperty; again justlike a FIELD.

They maybe implemented as methods, but thats not our problem as a developer
calling them, thats a lower level.

They are there to give more extensibility to fields and a greater way to
control fields.

They are wrappers for fields (conceptually), and wrappers for methods
(implentation).

So Yes, they are there to give an impression of fields.


"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<di********@discussion.microsoft.com> wrote:
It would be nice and a natural way to use a property set by permitting it to be set via a REF parameter on a method call.


I'm afraid I don't agree...
Why this isnt being allowed is beyond me, yes I know they are wrappers for get_ and set_ methods but if they are there to give the impression of a
FIELD, then they should have all the functionality of a field and not some half brained implementation.


No, because they're simply *not* fields. Passing a variable by
reference creates another variable with the same memory slot - that
just isn't how properties work. Developers should have a clear view
that properties are really methods in disguise rather than fields in
disguise.

Passing variables by reference should usually be avoided anyway, to be
honest - it's usually a sign of a method trying to do too much.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #3
<di********@discussion.microsoft.com> wrote:
They are giving the impression of fields, thats why we can do a
SomeObj.SomeProperty = someValue just like a field assignment, same for get
someVal = SomeObj.SomeProperty; again justlike a FIELD.
Yes, but that doesn't mean they should (or do) behave like fields in
every possible way.
They maybe implemented as methods, but thats not our problem as a developer
calling them, thats a lower level.
No it's not, really. It's all in the C# specification. Properties *are*
just methods in disguise, and any developer who doesn't get to grips
with that is going to get confused. For instance, have you ever heard
of a field you can assign to but not use the value of? And yet there
are properties which only have setters but no getters. Similarly,
straight assignment can't throw exceptions etc.
They are there to give more extensibility to fields and a greater way to
control fields.

They are wrappers for fields (conceptually), and wrappers for methods
(implentation).
No, they are wrappers for the state of the object, which needn't be
represented by fields.
So Yes, they are there to give an impression of fields.


They're there to give the easy syntax of fields, but that doesn't mean
they should be regarded as fields.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4
You're a tard in disguise.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<di********@discussion.microsoft.com> wrote:
They are giving the impression of fields, thats why we can do a
SomeObj.SomeProperty = someValue just like a field assignment, same for get someVal = SomeObj.SomeProperty; again justlike a FIELD.


Yes, but that doesn't mean they should (or do) behave like fields in
every possible way.
They maybe implemented as methods, but thats not our problem as a developer calling them, thats a lower level.


No it's not, really. It's all in the C# specification. Properties *are*
just methods in disguise, and any developer who doesn't get to grips
with that is going to get confused. For instance, have you ever heard
of a field you can assign to but not use the value of? And yet there
are properties which only have setters but no getters. Similarly,
straight assignment can't throw exceptions etc.
They are there to give more extensibility to fields and a greater way to
control fields.

They are wrappers for fields (conceptually), and wrappers for methods
(implentation).


No, they are wrappers for the state of the object, which needn't be
represented by fields.
So Yes, they are there to give an impression of fields.


They're there to give the easy syntax of fields, but that doesn't mean
they should be regarded as fields.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #5
<di********@discussion.microsoft.com> skrev i en meddelelse
news:eK**************@TK2MSFTNGP11.phx.gbl...
You're a tard in disguise.


and you are not really showing the nicest sides of you... hopefully

/Kim

Nov 15 '05 #6
And i care?
"Kim Nørby Andersen" <kn*@removethis.multihouse.dk> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
<di********@discussion.microsoft.com> skrev i en meddelelse
news:eK**************@TK2MSFTNGP11.phx.gbl...
You're a tard in disguise.


and you are not really showing the nicest sides of you... hopefully

/Kim

Nov 15 '05 #7
Discussion@,

When you set a field, say; x = 3; the field is set, period.

When you set a property, alot of work can be done;

for example;
myObject.x = 3

inside myObject...

public property x
{
set
{
if(value == something)
{
call some method;
call another method;

}
else if(value == something else)
{
call some other method;
}
else
{
throw ThisValueIsRealyBadException;
}
}
}

you cant do that by just setting a field.
Properties aren't just for LowLevel programmers. Anyone who has to derive a
class or who creates custom Textbox because he/she needs more functionality
would need to know this.

Marco
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<di********@discussion.microsoft.com> wrote:
They are giving the impression of fields, thats why we can do a
SomeObj.SomeProperty = someValue just like a field assignment, same for get someVal = SomeObj.SomeProperty; again justlike a FIELD.


Yes, but that doesn't mean they should (or do) behave like fields in
every possible way.
They maybe implemented as methods, but thats not our problem as a developer calling them, thats a lower level.


No it's not, really. It's all in the C# specification. Properties *are*
just methods in disguise, and any developer who doesn't get to grips
with that is going to get confused. For instance, have you ever heard
of a field you can assign to but not use the value of? And yet there
are properties which only have setters but no getters. Similarly,
straight assignment can't throw exceptions etc.
They are there to give more extensibility to fields and a greater way to
control fields.

They are wrappers for fields (conceptually), and wrappers for methods
(implentation).


No, they are wrappers for the state of the object, which needn't be
represented by fields.
So Yes, they are there to give an impression of fields.


They're there to give the easy syntax of fields, but that doesn't mean
they should be regarded as fields.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #8
di********@discussion.microsoft.com wrote:
Hi,

It would be nice and a natural way to use a property set by
permitting it to be set via a REF parameter on a method call.

Why this isnt being allowed is beyond me, yes I know they are
wrappers for get_ and set_ methods but if they are there to give the
impression of a FIELD, then they should have all the functionality of
a field and not some half brained implementation.


The normal reason for doing what you want is that the type of a value is
large, so passing a reference to it, rather than a copy of the value, is
faster and more memory efficient. However properties are almost always small
values, essentially value types of built-in types, so passing references is
unnecessary. Finally properties themselves do not hold references, and do
not even have to relate to actual data values, so there is no reason to pass
a reference to set them as if they were references to objects.

As others have mentioned, although a property may be thought of as a data
value, or a field in .NET terms, it doesn't have to be one at all.
Nov 15 '05 #9
Well, I guess the lesson here is to always answer questions with what we think
the person wants to hear instead of what we actually think - or just not
answer questions at all because we're sure to just get bitchy attitute in
return. Yeah, that's how I like to spend my time - generously trying to
answer questions of someone who's probably going to call me names.

Ah - Usenet.

On Thu, 18 Dec 2003 15:44:10 +0100, <di********@discussion.microsoft.com>
wrote:
And i care?
"Kim Nørby Andersen" <kn*@removethis.multihouse.dk> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
<di********@discussion.microsoft.com> skrev i en meddelelse
news:eK**************@TK2MSFTNGP11.phx.gbl...
> You're a tard in disguise.


and you are not really showing the nicest sides of you... hopefully

/Kim


Nov 15 '05 #10
Steve,

Most of us, with the exception of a chosen few, really appreciate the
efforts taken to answer questions.

Thank you.

Marco
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:06********************************@4ax.com...
Well, I guess the lesson here is to always answer questions with what we think the person wants to hear instead of what we actually think - or just not
answer questions at all because we're sure to just get bitchy attitute in
return. Yeah, that's how I like to spend my time - generously trying to
answer questions of someone who's probably going to call me names.

Ah - Usenet.

On Thu, 18 Dec 2003 15:44:10 +0100, <di********@discussion.microsoft.com>
wrote:
And i care?
"Kim Nørby Andersen" <kn*@removethis.multihouse.dk> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
<di********@discussion.microsoft.com> skrev i en meddelelse
news:eK**************@TK2MSFTNGP11.phx.gbl...
> You're a tard in disguise.

and you are not really showing the nicest sides of you... hopefully

/Kim

Nov 15 '05 #11
Hi Steve,

I think that we should always answer when we can, these post are archives
all over the web, especially in google so these answers become part of the
public knowledge. It does not matter if the asker answer or just as this
case behave childish cause somebody else rebate his point of view.
The answer of Jon is a good explanation of where the properties sits
between methods and fields, Thank jon, that was a clever description of
them.

The rest was just a waste of bandwidth.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:06********************************@4ax.com...
Well, I guess the lesson here is to always answer questions with what we think the person wants to hear instead of what we actually think - or just not
answer questions at all because we're sure to just get bitchy attitute in
return. Yeah, that's how I like to spend my time - generously trying to
answer questions of someone who's probably going to call me names.

Ah - Usenet.

On Thu, 18 Dec 2003 15:44:10 +0100, <di********@discussion.microsoft.com>
wrote:
And i care?
"Kim Nørby Andersen" <kn*@removethis.multihouse.dk> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
<di********@discussion.microsoft.com> skrev i en meddelelse
news:eK**************@TK2MSFTNGP11.phx.gbl...
> You're a tard in disguise.

and you are not really showing the nicest sides of you... hopefully

/Kim

Nov 15 '05 #12
Actually no, the tard comes out and dictates how we all post on multiple
forums, like he owns the fluckin place. Get real.

He deserves what he gets.
Freakin tard.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ec**************@TK2MSFTNGP12.phx.gbl...
Hi Steve,

I think that we should always answer when we can, these post are archives
all over the web, especially in google so these answers become part of the public knowledge. It does not matter if the asker answer or just as this
case behave childish cause somebody else rebate his point of view.
The answer of Jon is a good explanation of where the properties sits
between methods and fields, Thank jon, that was a clever description of
them.

The rest was just a waste of bandwidth.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:06********************************@4ax.com...
Well, I guess the lesson here is to always answer questions with what we

think
the person wants to hear instead of what we actually think - or just not
answer questions at all because we're sure to just get bitchy attitute in return. Yeah, that's how I like to spend my time - generously trying to
answer questions of someone who's probably going to call me names.

Ah - Usenet.

On Thu, 18 Dec 2003 15:44:10 +0100, <di********@discussion.microsoft.com> wrote:
And i care?
"Kim Nørby Andersen" <kn*@removethis.multihouse.dk> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
> <di********@discussion.microsoft.com> skrev i en meddelelse
> news:eK**************@TK2MSFTNGP11.phx.gbl...
> > You're a tard in disguise.
>
> and you are not really showing the nicest sides of you... hopefully
>
> /Kim
>
>
>


Nov 15 '05 #13
di********@discussion.microsoft.com wrote:
He deserves what he gets.


As will you. A bad attitude is a sure way to get ignored. And your views
on properties having field semantics are totally off the mark.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #14

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

Similar topics

1
by: Whitney | last post by:
On the left side of the main webpage I have some menu options that have a drop-down feature that is controlled with javascript. You click on the main heading and the links for that section show up....
11
by: | last post by:
Hi, It would be nice and a natural way to use a property set by permitting it to be set via a REF parameter on a method call. Why this isnt being allowed is beyond me, yes I know they are...
1
by: serge calderara | last post by:
Dear all, For my application I need to handle licencing as every software. For that I have a demo licence and a runtime licence which can expired after 30 days for the demo and base on a date...
0
by: mews.microsoft.com | last post by:
My ASP.NET pages record the referal url for each current page into session. This is then being used by the cancel button to go back to the calling page. Page Navigation is achieved thru'...
8
by: Jeroen Smits | last post by:
To Microsoft or other people who are interested, I have a feature request: I would really like to have an option to 'hide' a property or method from an inherited class. For example when I create...
18
by: Kamen Yotov | last post by:
hi all, i first posted this on http://msdn.microsoft.com/vcsharp/team/language/ask/default.aspx (ask a c# language designer) a couple of days ago, but no response so far... therefore, i am...
30
by: Raymond Hettinger | last post by:
Proposal -------- I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: >>> map(None,...
7
by: Ido Samuelson | last post by:
Hello, What do you think about the following features: public class GenericDecorator<T: T { } can leverage to a few things:
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
2
by: Doogie | last post by:
Hi, I'm writing Javascript code to parse out a query string. I want to handle the case where a parameter value may not be sent. So consider a parameter called "State". If the user doesn't pass...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.