www.digitalmars.com         C & C++   DMDScript  

D - The Hokey Cokey :)

reply "chris jones" <flak clara.co.uk> writes:
Whats the diferance between out and inout? In Delphi there is the var
keyword which i guese is the same as out as is basicly 'pass by referance',
although it does have one ambiguity where if you need to pass an object by
referance does the callee or called function create and clean up the object.
I geuse this isnt a problem with a GC. So anyway  i have an idea...

if you have a function

void foo(int x, int y, out a, out  h);

how about allowing the syntax to call the function...

(p, q) = foo(x,y);

which would be treated as identical to

foo(x,y, out p, out q)

so it would be purely cosmetic, much nicer to look at ihmo. Mabey there
would need to be the limitation that it can only be used with functions with
no return type?

chris
Sep 07 2002
next sibling parent "chris jones" <flak clara.co.uk> writes:
"chris jones" <flak clara.co.uk> wrote in message
news:ale82d$v0o$1 digitaldaemon.com...
 Whats the diferance between out and inout? In Delphi there is the var
 keyword which i guese is the same as out as is basicly 'pass by

 although it does have one ambiguity where if you need to pass an object by
 referance does the callee or called function create and clean up the

 I geuse this isnt a problem with a GC. So anyway  i have an idea...

 if you have a function

 void foo(int x, int y, out a, out  h);

should be void foo(int x, int y, out float a, out float h);
Sep 07 2002
prev sibling next sibling parent reply "Walter" <walter digitalmars.com> writes:
"chris jones" <flak clara.co.uk> wrote in message
news:ale82d$v0o$1 digitaldaemon.com...
 Whats the diferance between out and inout?

An inout passes a reference to a value in, which can be modified. An out passes a reference to an uninitialized value; the function is expected to initialize it.
Sep 07 2002
parent "chris jones" <flak clara.co.uk> writes:
"Walter" <walter digitalmars.com> wrote in message
news:aleesk$1dfd$1 digitaldaemon.com...
 "chris jones" <flak clara.co.uk> wrote in message
 news:ale82d$v0o$1 digitaldaemon.com...
 Whats the diferance between out and inout?

An inout passes a reference to a value in, which can be modified. An out passes a reference to an uninitialized value; the function is expected to initialize it.

It makes sense now. chris
Sep 09 2002
prev sibling parent "Sean L. Palmer" <seanpalmer earthlink.net> writes:
I really like the idea of tuples, which are inherently just anonymous
structs.  Tuples can be used as parameter lists or multiple return values or
anywhere you'd use a regular struct.  They replace the std::pair template in
C++ among other things.

Then treat the return values and parameter lists of functions in the
language as just being tuples, and you're set.  You construct a tuple with
(a,b,c) syntax and if the types match or are convertible, it can be assigned
to a compatible tuple or struct.  I'd support naming tuple members (such as
parameter list identifiers) (int a, int b, char[] c) and initialization by
named fields.  (a:1,b:2,c:"foo")

Sean

"chris jones" <flak clara.co.uk> wrote in message
news:ale82d$v0o$1 digitaldaemon.com...
 Whats the diferance between out and inout? In Delphi there is the var
 keyword which i guese is the same as out as is basicly 'pass by

 although it does have one ambiguity where if you need to pass an object by
 referance does the callee or called function create and clean up the

 I geuse this isnt a problem with a GC. So anyway  i have an idea...

 if you have a function

 void foo(int x, int y, out a, out  h);

 how about allowing the syntax to call the function...

 (p, q) = foo(x,y);

 which would be treated as identical to

 foo(x,y, out p, out q)

 so it would be purely cosmetic, much nicer to look at ihmo. Mabey there
 would need to be the limitation that it can only be used with functions

 no return type?

 chris

Sep 08 2002