Reference Types and Value Types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Champika Nirosh

    #16
    Re: Reference Types and Value Types


    "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
    news:MPG.1bd464 edd50b448798b65 2@msnews.micros oft.com...[color=blue]
    > Champika Nirosh <test@test.lk > wrote:[color=green]
    > > I think it is not a fair comment...
    > >
    > > "Everything is passed by value by default"[/color]
    >
    > It's a true comment. The only things which can be passed are value
    > types and references. Both of those are passed by value by default.
    >[/color]

    10: Very correct here you made the coment saying "only things which can be
    passed are value
    types and references. " it was not their earlier..
    [color=blue][color=green]
    > > Instead.. What you would said is.. reference of the reference type[/color][/color]
    variable[color=blue][color=green]
    > > is passed by its' value.. or object references are passed by value by
    > > default..[/color]
    >
    > But that's all that *can* be passed. Note that it's not the reference
    > of the reference type variable - it's the *value* of a reference type
    > variable, and that value is a reference.
    >[/color]

    Do you see any difference, when u take the whole sentence..??
    [color=blue][color=green]
    > > You statement is misleading... One might take it as .. object also[/color][/color]
    passed by[color=blue][color=green]
    > > its' value.. what happen actaully is since reference type cannot passed[/color][/color]
    by[color=blue][color=green]
    > > value even though you try they passes their reference..[/color]
    >
    > If that's all I'd said, you'd be right. However, look at what I *did*
    > say:
    >
    > <quote>
    > Not true. Everything is passed by value by default - whether the value
    > is a struct or a reference. You can't pass an actual *object* either by
    > reference or by value.
    > </quote>
    >
    > Now, how can *that* be taken as "object also passed by its value"?
    >[/color]

    Goto 10 please.....
    [color=blue]
    > --
    > Jon Skeet - <skeet@pobox.co m>
    > http://www.pobox.com/~skeet
    > If replying to the group, please do not mail me too[/color]


    Comment

    • Jon Skeet [C# MVP]

      #17
      Re: Reference Types and Value Types

      Champika Nirosh <test@test.lk > wrote:[color=blue][color=green][color=darkred]
      > > > I think it is not a fair comment...
      > > >
      > > > "Everything is passed by value by default"[/color]
      > >
      > > It's a true comment. The only things which can be passed are value
      > > types and references. Both of those are passed by value by default.
      > >[/color]
      >
      > 10: Very correct here you made the coment saying "only things which can be
      > passed are value types and references. " it was not their earlier..[/color]

      I think it was implied by my statement, actually (the "whether the
      value is a struct or a reference" clause). Maybe it's something
      that would be picked up by a native English speaker but not a
      non-native English speaker though, in which case I apologise. I'm aware
      that in international forums like this it helps to be specific.

      However, given what I said I still believe it's impossible to take from
      my paragraph the idea that an object itself can be passed by value, as
      I specifically denied that.
      [color=blue][color=green][color=darkred]
      > > > Instead.. What you would said is.. reference of the reference type[/color][/color]
      > variable[color=green][color=darkred]
      > > > is passed by its' value.. or object references are passed by value by
      > > > default..[/color]
      > >
      > > But that's all that *can* be passed. Note that it's not the reference
      > > of the reference type variable - it's the *value* of a reference type
      > > variable, and that value is a reference.[/color]
      >
      > Do you see any difference, when u take the whole sentence..??[/color]

      Yes. If people start thinking that it's a reference to the variable
      itself which is passed, then that gets into the territory of passing
      *by* reference, IMO.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Champika Nirosh

        #18
        Re: Reference Types and Value Types


        "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
        news:MPG.1bd469 7fb78c08c398b65 3@msnews.micros oft.com...[color=blue]
        > Champika Nirosh <test@test.lk > wrote:[color=green][color=darkred]
        > > > > I think it is not a fair comment...
        > > > >
        > > > > "Everything is passed by value by default"
        > > >
        > > > It's a true comment. The only things which can be passed are value
        > > > types and references. Both of those are passed by value by default.
        > > >[/color]
        > >
        > > 10: Very correct here you made the coment saying "only things which can[/color][/color]
        be[color=blue][color=green]
        > > passed are value types and references. " it was not their earlier..[/color]
        >
        > I think it was implied by my statement, actually (the "whether the
        > value is a struct or a reference" clause). Maybe it's something
        > that would be picked up by a native English speaker but not a
        > non-native English speaker though, in which case I apologise. I'm aware
        > that in international forums like this it helps to be specific.
        >[/color]

        I really apprecite this...
        [color=blue]
        > However, given what I said I still believe it's impossible to take from
        > my paragraph the idea that an object itself can be passed by value, as
        > I specifically denied that.
        >[/color]

        Not actauly the "object also passed by its value" forgive me .. I would have
        said "reference type variable also passed by its value"
        [color=blue][color=green][color=darkred]
        > > > > Instead.. What you would said is.. reference of the reference type[/color]
        > > variable[color=darkred]
        > > > > is passed by its' value.. or object references are passed by value[/color][/color][/color]
        by[color=blue][color=green][color=darkred]
        > > > > default..
        > > >
        > > > But that's all that *can* be passed. Note that it's not the reference
        > > > of the reference type variable - it's the *value* of a reference type
        > > > variable, and that value is a reference.[/color]
        > >
        > > Do you see any difference, when u take the whole sentence..??[/color]
        >
        > Yes. If people start thinking that it's a reference to the variable
        > itself which is passed, then that gets into the territory of passing
        > *by* reference, IMO.
        >[/color]

        But only if I haven't put "passed by its' value" at the end...
        [color=blue]
        > --
        > Jon Skeet - <skeet@pobox.co m>
        > http://www.pobox.com/~skeet
        > If replying to the group, please do not mail me too[/color]


        Comment

        • Jon Skeet [C# MVP]

          #19
          Re: Reference Types and Value Types

          Champika Nirosh <test@test.lk > wrote:[color=blue][color=green]
          > > However, given what I said I still believe it's impossible to take from
          > > my paragraph the idea that an object itself can be passed by value, as
          > > I specifically denied that.[/color]
          >
          > Not actauly the "object also passed by its value" forgive me .. I would have
          > said "reference type variable also passed by its value"[/color]

          I think it's a mistake to talk about the variable being passed by
          value, partly because it makes it harder to explain what happens when
          you've got an expression like "a+b" instead of a variable.

          "The value that is passed is the value of the expression (which may be
          a variable, a method call etc)" is perhaps clearer.

          You might want to have a look at
          http://www.pobox.com/~skeet/csharp/parameters.html for a more
          considered approach to this - that's how I write when I've got a bit
          more time, basically :)
          [color=blue][color=green][color=darkred]
          > > > > > Instead.. What you would said is.. reference of the reference type
          > > > variable
          > > > > > is passed by its' value.. or object references are passed by value[/color][/color]
          > by[color=green][color=darkred]
          > > > > > default..
          > > > >
          > > > > But that's all that *can* be passed. Note that it's not the reference
          > > > > of the reference type variable - it's the *value* of a reference type
          > > > > variable, and that value is a reference.
          > > >
          > > > Do you see any difference, when u take the whole sentence..??[/color]
          > >
          > > Yes. If people start thinking that it's a reference to the variable
          > > itself which is passed, then that gets into the territory of passing
          > > *by* reference, IMO.[/color]
          >
          > But only if I haven't put "passed by its' value" at the end...[/color]

          No, because you were talking about the "reference of the reference type
          variable". It's not entirely clear what you mean there - if you were to
          pass a reference *to* the variable by value, that would be very similar
          to passing the variable itself (not the variable's value, but the
          variable itself) by reference. Basically it's woolly terminology, and
          should be avoided IMO.)

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          • Champika Nirosh

            #20
            Re: Reference Types and Value Types

            Let me resume.. I think we both know about what we are talking... It is a
            matter of how deep u explain it

            Keep up the good work Jon..

            Nirosh.

            "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
            news:MPG.1bd46e 364dc4c2ae98b65 5@msnews.micros oft.com...[color=blue]
            > Champika Nirosh <test@test.lk > wrote:[color=green][color=darkred]
            > > > However, given what I said I still believe it's impossible to take[/color][/color][/color]
            from[color=blue][color=green][color=darkred]
            > > > my paragraph the idea that an object itself can be passed by value, as
            > > > I specifically denied that.[/color]
            > >
            > > Not actauly the "object also passed by its value" forgive me .. I would[/color][/color]
            have[color=blue][color=green]
            > > said "reference type variable also passed by its value"[/color]
            >
            > I think it's a mistake to talk about the variable being passed by
            > value, partly because it makes it harder to explain what happens when
            > you've got an expression like "a+b" instead of a variable.
            >
            > "The value that is passed is the value of the expression (which may be
            > a variable, a method call etc)" is perhaps clearer.
            >
            > You might want to have a look at
            > http://www.pobox.com/~skeet/csharp/parameters.html for a more
            > considered approach to this - that's how I write when I've got a bit
            > more time, basically :)
            >[color=green][color=darkred]
            > > > > > > Instead.. What you would said is.. reference of the reference[/color][/color][/color]
            type[color=blue][color=green][color=darkred]
            > > > > variable
            > > > > > > is passed by its' value.. or object references are passed by[/color][/color][/color]
            value[color=blue][color=green]
            > > by[color=darkred]
            > > > > > > default..
            > > > > >
            > > > > > But that's all that *can* be passed. Note that it's not the[/color][/color][/color]
            reference[color=blue][color=green][color=darkred]
            > > > > > of the reference type variable - it's the *value* of a reference[/color][/color][/color]
            type[color=blue][color=green][color=darkred]
            > > > > > variable, and that value is a reference.
            > > > >
            > > > > Do you see any difference, when u take the whole sentence..??
            > > >
            > > > Yes. If people start thinking that it's a reference to the variable
            > > > itself which is passed, then that gets into the territory of passing
            > > > *by* reference, IMO.[/color]
            > >
            > > But only if I haven't put "passed by its' value" at the end...[/color]
            >
            > No, because you were talking about the "reference of the reference type
            > variable". It's not entirely clear what you mean there - if you were to
            > pass a reference *to* the variable by value, that would be very similar
            > to passing the variable itself (not the variable's value, but the
            > variable itself) by reference. Basically it's woolly terminology, and
            > should be avoided IMO.)
            >
            > --
            > Jon Skeet - <skeet@pobox.co m>
            > http://www.pobox.com/~skeet
            > If replying to the group, please do not mail me too[/color]


            Comment

            Working...