Is is possible to get a named tuple from a struct type?
E.g.:
struct S { int foo; string bar; }
S s;
S.tupleof t; // S.tupleof is a tuple type, as opposed to s.tupleof,
// which yields a tuple instance
t[0] = 1;
t.bar = 2;
If not, I think it would be quite useful.
Even still,
Ellery Newcomer:
int a = 1, *b = null;
Walter has disallowed code like this in D because in C it is a well known
source of bugs (so much that C style guides strongly suggest to declare only
each variable in a distinct statement and line of code).
auto a = 1, b = null;
I have discussed
On 2011-01-08 09:15, Guilherme Vieira wrote:
Is is possible to get a named tuple from a struct type?
E.g.:
struct S { int foo; string bar; }
S s;
S.tupleof t; // S.tupleof is a tuple type, as opposed to s.tupleof,
// which yields a tuple instance
t[0] = 1;
eg. to return a fibonacci delegate:
return (ulong m) {
if(m 2) return m ;
return _self_ref(m-1)+_self_ref(m-2) ;
} ;
Is it possible? Thank you!
On 01/08/2011 04:45 PM, tsukikage wrote:
eg. to return a fibonacci delegate:
return (ulong m) {
if(m 2) return m ;
return _self_ref(m-1)+_self_ref(m-2) ;
} ;
Is it possible? Thank you!
http://en.wikipedia.org/wiki/Fixed_point_combinator#Y_combinator
I don't think there's a built in way to
As a workaround you can do this for now:
import std.stdio;
enum deleg = returnFib();
ulong delegate(ulong m) returnFib()
{
return (ulong m)
{
if(m 2)
return m;
return deleg(m-1)+deleg(m-2);
};
}
void main()
{
writeln(returnFib()(10));
}
Otherwise
On 08/01/2011 16:00, Pelle wrote:
snip
http://en.wikipedia.org/wiki/Fixed_point_combinator#Y_combinator
snip
How are you getting around D not supporting recursively defined types?
Stewart.
On 08/01/2011 17:40, Andrej Mitrovic wrote:
snip
Otherwise I'd really like the ability for a lambda to call itself.
Perhaps a feature request is in order.
I'm not sure what D would gain in practice. If you want a function that
calls itself, why not just name the function?
Stewart.
On 1/8/11, Stewart Gordon smjg_1...@yahoo.com wrote:
On 08/01/2011 17:40, Andrej Mitrovic wrote:
snip
Otherwise I'd really like the ability for a lambda to call itself.
Perhaps a feature request is in order.
I'm not sure what D would gain in practice. If you want a function that
calls
Thank Pelle , and others.
I'm thinking ways to do this task :
http://rosettacode.org/wiki/Anonymous_recursion
With this last version of Y-combinator
http://rosettacode.org/wiki/Y_combinator#D ,
it look like this:
ulong fib(long n) {
if(n 0) throw new Exception(No negative) ;
return
On Sat, 08 Jan 2011 20:34:39 +, Sean Eskapp wrote:
if(left == null)
1) write if (left is null) instead if checking for null. Equality
operator is rewritten to a.opEquals(b), which you don't want if you
checking for null.
this()
{
left = right = null;
}
2) default
Sean Eskapp napisał(a):
I had some code that was segfaulting, so I rewrote the basic idea as a
fibonacci function, and lo and behold, it still segfaults. Why, and how
to fix?
This looks fishy:
class Fib
{
private const Fib* left, right;
...
this(in Fib left, in Fib right)
Use case:
import std.variant;
void foo (Variant v) {}
void main () {
Variant v = 3; // ok, this () called
v = 3; // ok, opAssing called
foo (v); // ok, struct copy, this(this) called
foo (3); // error
}
I'm trying to understand what is needed to make
What method are you using to test the memory?
I'm puzzled that you've put a comment there rather than the code you're
actually
using.
I'm not using code, I'm checking the working set of my process in Task Manager,
and through every iteration, it adds 128 MB.
If you run this code twice,
where did libdruntime.a go in dmd.2.051.zip:/linux/lib ?
Unfortunately I can't provide a simple test case, but I have a case where using:
writef(..\n);
inside a loop that runs a dozen times does not print out each line as the
statement is reached, instead it prints out everything at once when the
application is done. If I use this:
Tomek got it right. Fixed by copying the objects, rather than using pointers.
Thanks!
On Saturday 08 January 2011 13:32:19 Ellery Newcomer wrote:
where did libdruntime.a go in dmd.2.051.zip:/linux/lib ?
I think that it's included inside of libphobos.a now, and has been for a few
releases. The libraries are still separate, and you can build them separately,
but from what I can
On 01/08/2011 09:02 PM, Jonathan M Davis wrote:
On Saturday 08 January 2011 13:32:19 Ellery Newcomer wrote:
where did libdruntime.a go in dmd.2.051.zip:/linux/lib ?
I think that it's included inside of libphobos.a now, and has been for a few
releases. The libraries are still separate, and you
On Saturday 08 January 2011 19:16:26 Ellery Newcomer wrote:
On 01/08/2011 09:02 PM, Jonathan M Davis wrote:
On Saturday 08 January 2011 13:32:19 Ellery Newcomer wrote:
where did libdruntime.a go in dmd.2.051.zip:/linux/lib ?
I think that it's included inside of libphobos.a now, and has
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article
On Saturday 08 January 2011 22:01:11 %u wrote:
Isn't it possible to have a hierarchy in interface definitions such that it
is possible to overload according to best interface match?
This now won't compile due to multiple
21 matches
Mail list logo