Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. dotNET Rant [modified]

dotNET Rant [modified]

Scheduled Pinned Locked Moved The Lounge
questioncsharpcomlearning
101 Posts 25 Posters 40 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T TheGreatAndPowerfulOz

    ok, this is not a programming question. It's a rant! given,

    object one = 0;
    object two = 0;
    bool same = one == two;

    what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

    Fight Big Government:
    http://obamacareclassaction.com/
    http://obamacaretruth.org/

    modified on Friday, May 7, 2010 1:08 AM

    G Offline
    G Offline
    Grant BlahaErath
    wrote on last edited by
    #101

    ahmed zahmed ranted about == not measuring underlying boxed types in: http://www.codeproject.com/Lounge.aspx?msg=3464288#xx3464288xx
    The mechanism is explained in the thread, but the more interesting question is why Hejlsberg et al. would design the language this way. Certainly, there are other languages that just bundle value and reference comparison into one operator. My first guess would be performance since it could be costly to have the compiler generate reflection checks to see if every object was an underlying boxed value type. The other thought is that comparison operators are always static (and can't polymorph). Again, that makes sense from a performance perspective as well since there would be no need to deref to a jump table for every == operation. Since there are some great scenarios for polymorphing comparison, there is the .Equals on every object. More overhead, but the choice to use the abstraction is in the hands of the coder. There are also languages that only do this (and hence stuff == into some kind of table). Anyone see any other reason than performance? Maybe 'cause Java did it? :-)

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups