DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Strangest language feature  (Read 6,428 times)

Eóin

  • O'Callaghan
  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
Strangest language feature
« on: December 09, 2010, 05:13 PM »
Fantastic question (thread?) from over on stack overflow. Plenty of things in there I never knew about. For example:

Quote from: http://stackoverflow.com/questions/1995113/strangest-language-feature
In JavaScript:
'5' + 3 gives '53'
Whereas
'5' - 3 gives 2

From reddit originally

Interviewer: Is there anything you don't like?
Bjarne Stroustrup: Marketing hype as a substitute for technical argument. Thoughtless adherence to dogma. Pride in ignorance.

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award
Re: Strangest language feature
« Reply #1 on: December 09, 2010, 05:50 PM »
That was fun to read through.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Strangest language feature
« Reply #2 on: December 09, 2010, 06:07 PM »
ahk can't be too far behind with this usage:

Code
If 0 < 1
{
	MsgBox, 64, DummyApp Usage, Usage: DummyApp params
	ExitApp
}

To anyone coming from another programming language, the If statement should always be true, like "while 1" ... but not so!! :)

Renegade

  • Tell me something you don't know...
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,291
    • Participated in NANY Challenge Three Times
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: Strangest language feature
« Reply #3 on: December 10, 2010, 12:11 PM »
I liked this (Algol):

Code: (c#)
int a[3] = { 1, 2, 3 };
int i = 1;

void f(int j)
{
    int k;
    k = j;  // k = 2
    i = 0;
    k = j;  // k = 1 (!?!)    
}

int main()
{
    f(a[i]);
}

At first glance, it looks hosed, but reading through starting at main() it makes perfect sense. My question then is... Sanity? Are you there? :P :D

Thanks for that link! Some very cool stuff in there.
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Re: Strangest language feature
« Reply #4 on: December 10, 2010, 12:14 PM »
Renegade: ugh, everything is passed by reference?
- carpe noctem

Eóin

  • O'Callaghan
  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,401
Re: Strangest language feature
« Reply #5 on: December 10, 2010, 12:55 PM »
Even if passed by ref that still doesn't make much sense :D
Interviewer: Is there anything you don't like?
Bjarne Stroustrup: Marketing hype as a substitute for technical argument. Thoughtless adherence to dogma. Pride in ignorance.

f0dder

  • [Well, THAT escalated quickly!]
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
    • Participated in NANY Challenge Once
Re: Strangest language feature
« Reply #6 on: December 10, 2010, 03:05 PM »
Even if passed by ref that still doesn't make much sense :D
No, it would have to be... copied by reference? :P - very strange behavior for what I would expectto be a value type.
- carpe noctem

Original address: https://www.donationcoder.com/forum/index.php?topic=24836.0