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. Thought about programming

Thought about programming

Scheduled Pinned Locked Moved The Lounge
questiondiscussiontutorial
61 Posts 18 Posters 6 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.
  • B Brit

    I've thought about that, too. It's a little hard to use in certain cases, though -- for example if you want to pass a value directly to another function. I mainly wish for it when I have multiple ins and outs from a function (and some variables are in+out). Sometimes I can't tell which variables are which -- hence the "tuple" thing, because return values are always out. In general, I compensate for this by using pointers (not references) for all out variables (of course, I can't tell if a variable is in+out or just out). The end result looks like this: int a,b; FooBar( &a, &b ); See the "address of" operator? That tells me that it's an out variable. If you use references you simply can't tell. Are "a" and/or "b" input, output, or both? FooBar( a,b ); I've also considered the possibility of a different argument syntax. For example, forcing programmers to break arguments into separate input and output sections (where a,b are "in" and c,d are "out" variables): int a, b, c, d; MyFunc( a,b )( c,d ); That syntax doesn't address in+out variables. Some other variation might be useful for that (because I hesitate to add even more parenthesis). (e is in+out) MyFunc( a,b; e; c,d ); Kinda looks like a "for" statement, doesn't it? ------------------------------------------ "Isn't it funny how people say they'll never grow up to be their parents, then one day they look in the mirror and they're moving aircraft carriers into the Gulf region?" - The Onion

    J Offline
    J Offline
    Jamie Nordmeyer
    wrote on last edited by
    #61

    How about this:

    (int, int)MyFunc(int x, int y)
    {
    if (x < y)
    return x, y;
    else
    return y, x;
    }

    int main()
    {
    int x, y;

    (x, y)=MyFunc(6, 10);
    .
    .
    .
    }

    Or maybe

    MyFunc(int x, int y) returns (int, int)
    {
    if (x < y)
    return x, y;
    else
    return y, x;
    }

    int main()
    {
    int x, y;

    (x, y)=MyFunc(6, 10);
    .
    .
    .
    }

    Jamie Nordmeyer Portland, Oregon, USA

    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