On 10/18/18 12:11 PM, aliak wrote:
On Thursday, 18 October 2018 at 14:11:36 UTC, Steven Schveighoffer wrote:
Yes, but that's what lazy variables do.
Not in Swift at least...
Apparently so (I have not used them before), but this is D! So you
should be aware that lazy parameters work that w
On Thursday, 18 October 2018 at 16:10:04 UTC, aliak wrote:
On Thursday, 18 October 2018 at 14:16:56 UTC, Simen Kjærås
wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
What the language doesn't prov
On Thursday, 18 October 2018 at 14:16:56 UTC, Simen Kjærås wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
What the language doesn't provide, it generally provides the
tools to make:
struct Lazy
On Thursday, 18 October 2018 at 14:11:36 UTC, Steven
Schveighoffer wrote:
Yes, but that's what lazy variables do.
-Steve
Not in Swift at least...
On Thursday, 18 October 2018 at 14:08:11 UTC, aliak wrote:
On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus
wrote:
auto x = () {
// do some heavy stuff
};
if (condition) {
func(x().y); // heavy stuff evaluated here
}
That would do heavy stuff everytime i wanted to get y tho
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
What the language doesn't provide, it generally provides the
tools to make:
struct Lazy(T) {
T delegate() _payload;
this(lazy T t) {
_payl
On 10/18/18 10:08 AM, aliak wrote:
On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
auto x = () {
//
On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
auto x = () {
// do some heavy stuff
};
if (conditio
On 10/17/18 3:32 AM, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're parameters)?
i.e:
struct S {
//...
int y;
//...
}
/*
lazy S x = () {
// do some heavy stuff
}();
*/
auto x() { // do some heavy stuff
}
if (condition) {
func(x.y); // heavy
On Wednesday, 17 October 2018 at 20:32:40 UTC, Ali Çehreli wrote:
On 10/17/2018 12:32 AM, aliak wrote:
[...]
Not very clean but something like this:
import std.stdio;
struct LazyVar(alias exp) {
alias T = typeof(exp());
T value() {
static bool initialized = false;
sta
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
auto x = () {
// do some heavy stuff
};
if (condition) {
func(x().y); // heavy stuff evaluated here
}
If you want
On 10/17/2018 12:32 AM, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're parameters)?
i.e:
struct S {
//...
int y;
//...
}
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
Cheers,
- Ali
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
i.e:
struct S {
//...
int y;
//...
}
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
On 01/11/2010 16:20, Jonathan M Davis wrote:
1. I 'm stunned that the compiler doesn't complain about you declaring f as
void. It strikes me as a bug with lazy. You can't declare variables of type
void. It makes no sense.
It isn't a bug. Read the documentation on lazy - D explicitly supports
On 01/11/2010 15:57, Adam Cigánek wrote:
void capture(lazy void f) {
fun =&f;
}
It says "Error: lazy variables cannot be lvalues", pointing to the
"fun =&f" line.
Because f doesn't have an address. It's just an expression that's
evaluated where it's used. It's true that the fu
On Monday, November 01, 2010 08:57:09 Adam Cigánek wrote:
> Hello,
>
> why is the following code illegal?
>
>
> import std.stdio;
>
> void delegate() fun;
>
> void capture(lazy void f) {
> fun = &f;
> }
>
> void main() {
> capture(writeln("hello"));
> fun();
> }
>
>
16 matches
Mail list logo