You don't need to use dereference operator. Example:
http://dpaste.dzfl.pl/d34c23e5
import std.stdio;
struct Foo {
void answer() {
writeln(As you wish!);
}
}
void main() {
Foo veryVeryLongNamedStruct;
auto v = veryVeryLongNamedStruct;
v.answer();
}
Oh, it doesn't work when accessing member data. Sorry for the
noise.
On Monday, 29 July 2013 at 21:25:21 UTC, Temtaime wrote:
No, i cannot.
struct S {
uint longnamed;
}
void main() {
S somestruct;
alias v = somestruct.longnamed;
writeln(v);
}
Error: need 'this' for 'longnamed' of type 'uint'
Is it a bug ?
I'd say this is
On Monday, 29 July 2013 at 23:02:57 UTC, JS wrote:
__FUNCTION__ does not return anything when used in templates.
For debugging purposes I sometimes use pragma(msg,
template_name); (with template_name being the name of the
template assigned an enum)
It can be relatively trivial or incredibly
On Tuesday, 30 July 2013 at 06:36:12 UTC, Dicebot wrote:
On Monday, 29 July 2013 at 23:02:57 UTC, JS wrote:
__FUNCTION__ does not return anything when used in templates.
For debugging purposes I sometimes use pragma(msg,
template_name); (with template_name being the name of the
template
Alternative:
import std.stdio;
struct S {
uint longnamed;
alias longnamed this;
}
void main() {
S somestruct;
alias v = somestruct;
writeln(v);
v++;
writeln(v);
}
On Tuesday, 30 July 2013 at 01:19:23 UTC, Meta wrote:
On Tuesday, 30 July 2013 at 01:06:39 UTC, Meta wrote:
Does this code do what you want, or are there other
requirements as well?
void Pragma(alias amsg)(string file = __FILE__)
{
pragma(msg, amsg);
}
Actually, sorry, that's the
On Monday, 29 July 2013 at 23:09:20 UTC, JS wrote:
I have created a template Pragma that emulates pragma but
better, the problem is that I have to assign it to something
which is very redundant in my code:
enum temp = Pragma!(msg)
e.g.,
template Pragma(alias amsg)
{
string Pragma(string
On Tuesday, 30 July 2013 at 07:12:11 UTC, Namespace wrote:
On Monday, 29 July 2013 at 23:09:20 UTC, JS wrote:
I have created a template Pragma that emulates pragma but
better, the problem is that I have to assign it to something
which is very redundant in my code:
enum temp = Pragma!(msg)
Whats the difference between a final and non-final switch
statement? I know the compiler complains when i don't use a
default case in a non-final switch statement but i've no idea why.
On Tuesday, 30 July 2013 at 10:14:50 UTC, Gary Willoughby wrote:
Whats the difference between a final and non-final switch
statement? I know the compiler complains when i don't use a
default case in a non-final switch statement but i've no idea
why.
On Tuesday, 30 July 2013 at 06:45:31 UTC, JS wrote:
void f()
{
pragma(msg, __FUNCTION__);
}
template t()
{
pragma(msg, __FUNCTION__);
}
void main(string[] argv)
{
readln();
}
the function displays main.f. The template displays nothing.
I'd prefer it to display main.t! or
On Tuesday, 30 July 2013 at 10:45:26 UTC, Dicebot wrote:
On Tuesday, 30 July 2013 at 06:45:31 UTC, JS wrote:
void f()
{
pragma(msg, __FUNCTION__);
}
template t()
{
pragma(msg, __FUNCTION__);
}
void main(string[] argv)
{
readln();
}
the function displays main.f. The
On Tuesday, 30 July 2013 at 10:29:45 UTC, Namespace wrote:
On Tuesday, 30 July 2013 at 10:14:50 UTC, Gary Willoughby wrote:
Whats the difference between a final and non-final switch
statement? I know the compiler complains when i don't use a
default case in a non-final switch statement but
On Tuesday, 30 July 2013 at 11:04:10 UTC, JS wrote:
1. No, the code actually will print the message but the error
shows up right after(well, depends on which error, the one I
get inside templates works fine except the without the
assignment/alias, no further compilation is done due to the
On Tuesday, 30 July 2013 at 11:25:38 UTC, Dicebot wrote:
On Tuesday, 30 July 2013 at 11:04:10 UTC, JS wrote:
1. No, the code actually will print the message but the error
shows up right after(well, depends on which error, the one I
get inside templates works fine except the without the
Hello all,
I thought I'd share some profiling results from the graph/network library that
I've been working on -- see:
https://github.com/WebDrake/Dgraph
http://braingam.es/2013/07/complex-networks-in-d/
http://braingam.es/2013/07/complex-networks-in-d-part-2-building-the-network/
I'd like to
On Tuesday, 30 July 2013 at 07:02:51 UTC, JS wrote:
If I use enum or alias they both have the same problem(The
annoying mandatory assignment).
Can you post some more code that exhibits exactly the behaviour
you're describing? I can't replicate the problem you're having
with the code you
On Monday, 29 July 2013 at 06:17:10 UTC, Manfred Nowak wrote:
http://dlang.org/phobos/std_stdio.html:
void write(S...)(S args);
Writes its arguments in text format to the file.
1)
Feeding arguments in text format into the search-function for
the whole site does not give a hint to
On 07/30/2013 06:16 AM, Meta wrote:
Can you post some more code that exhibits exactly the behaviour you're
describing? I can't replicate the problem you're having with the code
you provided (nor the code *I* provided).
Ditto.
JS, I wrote the following code for you. Could you please start
On Tuesday, 30 July 2013 at 18:38:23 UTC, Ali Çehreli wrote:
On 07/30/2013 06:16 AM, Meta wrote:
Can you post some more code that exhibits exactly the
behaviour you're
describing? I can't replicate the problem you're having with
the code
you provided (nor the code *I* provided).
Ditto.
JS,
I have quite complicated data structure (class-based) and I need a copy of
it in a Task (std.parallelism). There is a simplification of data structure
and my program:
class A {
B [] arr;
}
class B {
C c;
}
class C {
A a;
}
void main () {
a = new A();
... // Further initialization of
On 07/30/2013 12:09 PM, JS wrote:
I already stated why this is not a proper example, I'm not using Pragma
in run time code(for lack of a better term).
module main;
import std.stdio;
template Pragma(alias amsg)
{
void Pragma(string file = __FILE__)
{
pragma(msg,
On Tuesday, 30 July 2013 at 20:34:32 UTC, Ali Çehreli wrote:
On 07/30/2013 12:09 PM, JS wrote:
I already stated why this is not a proper example, I'm not
using Pragma
in run time code(for lack of a better term).
module main;
import std.stdio;
template Pragma(alias amsg)
{
void
BTW, when I use mixin in my code, the error goes away but no
pragma msg is produced, so it is not a solution.
On Tuesday, 30 July 2013 at 11:25:38 UTC, Dicebot wrote:
On Tuesday, 30 July 2013 at 11:04:10 UTC, JS wrote:
1. No, the code actually will print the message but the error
shows up right after(well, depends on which error, the one I
get inside templates works fine except the without the
http://dpaste.dzfl.pl/cdabf9fa
But adding one more parameter gives an error!
http://dpaste.dzfl.pl/a5cfac37
Template has no effect simply because I added an parameter with a
default?!?!?!?
On Tuesday, 30 July 2013 at 22:22:38 UTC, JS wrote:
But adding one more parameter gives an error!
http://dpaste.dzfl.pl/a5cfac37
Copying the code for readability and for future generations:
template SomeName(T...)
{
void SomeName(string file = __FILE__, string line = __LINE__,
string f =
There are many ways to design a graph data structure. All of them
have tradeoffs, they can't be very good for everything.
For your benchmarks are you using the ldc2 compiler with correct
compilation switches?
map() should not allocate memory.
Sometimes lazy code is faster and sometimes it's
On Tuesday, 30 July 2013 at 22:22:38 UTC, JS wrote:
http://dpaste.dzfl.pl/cdabf9fa
But adding one more parameter gives an error!
http://dpaste.dzfl.pl/a5cfac37
Template has no effect simply because I added an parameter with
a default?!?!?!?
Definitely some compiler logic problems there
On Tuesday, 30 July 2013 at 23:02:40 UTC, bearophile wrote:
Sometimes you can keep memory allocation low, performance
almost acceptable, and code easy to read using a pre-allocated
scratch space plus using map() and copy() from std.algorithm.
Any chance of some nice examples of this?
John Colvin:
Any chance of some nice examples of this?
Allocate a buffer somewhere, on the stack or heap, and then
instead of using a map()+array() as in that code use map()+copy()
plus a test to be sure the space is sufficient.
But in the end I don't know how much well even ldc2 will
On 07/31/2013 01:02 AM, bearophile wrote:
There are many ways to design a graph data structure. All of them have
tradeoffs, they can't be very good for everything.
Sure, it's just that in this case the reference code (igraph) is _much_ more
performant. I'm keen to try and identify the major
On 07/30/2013 01:15 PM, Marek Janukowicz wrote:
class A {
B [] arr;
}
Now a in my task is the same as a in main thread and I'd like a local
copy - to be precise I need to make changes to a in the task, but they
should not affect main copy.
Fine: That is a requirement of your program.
Jesse Phillips wrote:
Writes its arguments in text format to the file.
I'm not sure what results you are interest in when searching for
arguments in text format.
I expected a closer explanation for the broad explanation arguments in
text format. If the explanation for `write' would be
35 matches
Mail list logo