On Wednesday, 15 August 2012 at 01:22:41 UTC, Era Scarecrow wrote:
On Wednesday, 15 August 2012 at 00:37:32 UTC, ReneSac wrote:
And my last question of my first post: I can't use auto for
the out values right? An enhancement proposal like this
would be compatible with D?
I would say No.
Thanks, this indeed works. One obvious (when your program
starts to behave weirdly...) down side of this solution: it needs
a different dummy for each optional out value of a function, or
else multiple variables will be modifying the same dummy.
And, of course, a different dummy for each type
On Wednesday, 15 August 2012 at 00:37:32 UTC, ReneSac wrote:
And my last question of my first post: I can't use auto for
the out values right? An enhancement proposal like this would
be compatible with D?
I would say No. Maybe if it was a union, but I don't think
so;.It still needs to
On 08/14/2012 06:22 PM, Era Scarecrow wrote:
On Wednesday, 15 August 2012 at 00:37:32 UTC, ReneSac wrote:
And my last question of my first post: I can't use auto for the
out values right? An enhancement proposal like this would be
compatible with D?
I would say No. Maybe if it was a
On Wednesday, 15 August 2012 at 01:42:11 UTC, Ali Çehreli wrote:
Agreed. The function code must be compiled to use certain
amount of data from the program stack for that particular
parameter. That size of that parameter must be known at compile
time.
The compiler could in theory examine the
On Tuesday, 24 July 2012 at 05:30:49 UTC, Ali Çehreli wrote:
The options that I can think of:
- Return a struct (or a class) where one of the members is not
filled-in
- Similarly, return a tuple
This is awkward, and doesn't look good for performance.
- Use an out parameter, which can
On 08/11/2012 03:48 PM, ReneSac wrote:
On Tuesday, 24 July 2012 at 05:30:49 UTC, Ali Çehreli wrote:
- Use an out parameter, which can have a default lvalue:
int g_default_param;
void foo(ref int i = g_default_param)
{
if (i == g_param) {
// The caller is not interested in 'i'
} else {
There is no compiler bug. You cannot pass immutable/rvalue by reference
to mutable.
On Tuesday, 24 July 2012 at 03:25:55 UTC, ReneSac wrote:
Do I really have to duplicate the function, in order to achieve
this?
In a nutshell, yes. Or else resort to bizarre sorcery such as
may rot the very heart from one's chest (or template ninjitsu,
whatever). But is it really so
Am 24.07.2012 05:25, schrieb ReneSac:
I whish there was:
auto foo() {
return Tuple!(foo, bar, 1, new Custum());
}
void main() {
auto (s1, s2, i, c) = foo();
}
On Tuesday, 24 July 2012 at 03:25:55 UTC, ReneSac wrote:
How I can return multiple values in D, but one of them being
optional?
One of the ways to to it is to return a tuple with your
arguments, where the last item of the tuple is a Nullable of the
optional element:
import std.stdio,
On Tuesday, 24 July 2012 at 08:56:21 UTC, David wrote:
Am 24.07.2012 05:25, schrieb ReneSac:
I whish there was:
auto foo() {
return Tuple!(foo, bar, 1, new Custum());
}
void main() {
auto (s1, s2, i, c) = foo();
}
I think the main blocker to something like that right now is the
It seems forum.dlang.org hides my first answer, I don't know why:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learnarticle_id=37708
Bye,
bearophile
On 07/23/2012 08:25 PM, ReneSac wrote:
How I can return multiple values in D, but one of them being optional? I
tried the 'out' hack to achieve multiple return values, but it didn't
accepted a default argument: it needed a lvalue in the calling function.
Like in C and C++, functions in D can
14 matches
Mail list logo