On Tuesday, 15 April 2014 at 18:02:00 UTC, bearophile wrote:
Steve Teale:
Since this is D-Learn, I can be indignant, and say that D
needs to get its act together, and have a clean definition of
'pure'. What you describe is not only undocumented, but also
far too complicated -
On Tuesday, 15 April 2014 at 09:41:57 UTC, bearophile wrote:
Yes, foo2 is weakly pure, but main is not tagged as pure, so
main is free to use a global reference. If you mark main pure,
your code will not compile even if you comment out the writeln.
D is working as designed here.
3) Using a r
On Monday, 14 April 2014 at 15:16:07 UTC, bearophile wrote:
Steven Schveighoffer:
For that reason, I would disallow out parameters from casting
implicitly.
A number of things perplex me here.
1) If I attempt to compile foo2() more or less as presented with
2.065, the compiler tells me:
Er
On Friday, 4 April 2014 at 15:15:55 UTC, bearophile wrote:
Bienlein:
What I was actually looking for was how to get this to work:
immutable int b = if(1 == 1) { return 123; } else { return
456; };
immutable b = (1 == 1) ? 123 : 456;
Bye,
bearophile
You said you did not like ternary expre
On Sunday, 23 March 2014 at 13:23:58 UTC, Dicebot wrote:
On Sunday, 23 March 2014 at 13:03:07 UTC, Adam D. Ruppe wrote:
That won't necessarily work in the presence of overloaded
functions since getMember only gets one of them.
Yeah, forgot to add this part, will make end result a bit less
pre
What's the cool/idiomatic D way to test at compile time if a
struct has a member function with a particular signature? Along
the lines of:
struct Unrelated
{
...
}
template isSomething(T)
{
enum bool isSomething = is(typeof(
(inout int = 0)
{
T???; // has a function void
This might be equivalent to 'How to do multiple inheritance in D'.
I have a class ControlSet, that is just a bunch of widgets. I use
it in various places to represent the contents of dialogs that
are associated with some class.
All such classes have to do is define themselves using the
CSTar
On Sunday, 9 March 2014 at 12:07:22 UTC, Steve Teale wrote:
Now suppose that my D shared library contains a class, rather
that just module ctors/dtors, how do I go about creating an
instance of that class and using its methods?
After wandering down several dead-end paths, and help from other
On Sunday, 9 March 2014 at 14:09:28 UTC, Tolga Cakiroglu wrote:
For this, you create an "Interface" that matches to the method
declaration of your class. But notice that instead of defining
methods, you will define attributes those types' match to that
class's methods. I did this before and
Martin Nowak's Gihub druntime Page has
module main;
import core.runtime, core.thread;
void main() {
auto lib = Runtime.loadLibrary("./liba.so");
auto thr = new Thread({
auto lib = Runtime.loadLibrary("./liba.so");
Runtime.unloadLibrary(lib);
});
thr.start();
t
On Friday, 7 March 2014 at 16:59:30 UTC, Bauss wrote:
What arguments would I do to compile a d project through
command line. Been trying a few things, but can't get it
working.
I always get "Error: cannot read file x"
Read around the net and it most says it's an installation error
and that r
On Thursday, 6 March 2014 at 18:36:12 UTC, Dejan Lekic wrote:
Template mixins can't contain statements, only declarations,
because they
(template mixins) are a way to inject code into the context.
Therefore it makes sense to forbid statements, as they can't
appear in ANY
context.
If I sid
Pretty much what the subject says. Why can't template mixins
include statements ans so on?
Is it just too hard, or is it just too much like C macros?
Steve
On Sunday, 2 March 2014 at 15:23:03 UTC, H. S. Teoh wrote:
This is a pretty good primer to templates:
https://semitwist.com/articles/article/view/template-primer-in-d
The trouble is with most of these tutorials that they offer
examples that are things you would probably never want to
On Sunday, 2 March 2014 at 10:05:05 UTC, Dicebot wrote:
There is nothing wrong about not using templates. Almost any
compile-time design can be moved to run-time and expressed in
more common OOP form. And using tool you have mastery of is
usually more beneficial in practice than following th
On Saturday, 1 March 2014 at 22:16:54 UTC, woh wrote:
You probably don't have a good understanding of templates if
you have only used 2 in your entire codebase. Or you are
talking about a very tiny codebase.
That's just what us template-blind people want to hear -
confirmation that we are i
On Friday, 28 February 2014 at 19:06:26 UTC, Dicebot wrote:
On Friday, 28 February 2014 at 18:42:57 UTC, Steve Teale wrote:
Is this typical - libraries use templates, applications don't,
or
am I just being unimaginative?
Steve
Also every time you catch yourself doing any sort of
All the D aficionados seem to wet their pants over
meta-programming, but I struggle to find a place to use it.
IIRC, I used it in a couple of places when I was trying to write
library stuff for MySQL, but in my current project, I use it only
once. That's when I want to stuff something onto my und
On Friday, 28 February 2014 at 16:02:26 UTC, Dicebot wrote:
...
Mmm, simple question, complicated answer. But the first one was
enough for me at this point.
On Friday, 28 February 2014 at 11:47:45 UTC, Vladimir Panteleev
wrote:
A "const" or "immutable" declaration would declare a constant
variable - meaning, unless it is optimized out at a later
point, it will end up in the data segment and have its own
address. An enum declares a manifest consta
Could someone please explain what you would use this for to an
old man rooted in C++, but who loves D.
Where does it fit in relative to 42?
;=(
Steve
On Thursday, 27 February 2014 at 18:13:43 UTC, Namespace wrote:
On Thursday, 27 February 2014 at 18:10:38 UTC, Steve Teale
wrote:
Could someone please explain what you would use this for to an
old man rooted in C++, but who loves D.
Where does it fit in relative to 42?
;=(
Steve
It'
On Wednesday, 26 February 2014 at 03:33:38 UTC, Jesse Phillips
wrote:
On Tuesday, 25 February 2014 at 14:32:42 UTC, Steve Teale wrote:
What does the somewhat cryptic DUB error
Trying to append absolute path.
mean.
By a process of elimination, the offending line in the json
file is
What does the somewhat cryptic DUB error
Trying to append absolute path.
mean.
By a process of elimination, the offending line in the json file
is
"importPaths": ["/usr/local/include/d/gtkd-2"]
Steve
If it's the same librsvg as below, then it looks like it has an
API function which can also load a SVG from memory:
https://developer.gnome.org/rsvg/2.40/RsvgHandle.html#rsvg-handle-new-from-data
To answer your original question, I think the best way to do
this is to create a pipe on the files
This is probably not exactly a D question.
The library librsvg expects to get an SVG file filename. I have
the data of such a file in memory.
How do I dress up that memory as a file with a name so that I can
pass the name to the librsvg open function.
I've looked at std.mmfile, and played w
Rather than change it to int/ulong, just change it to 'size_t
len = parent.children.length+1' (or auto instead of size_t).
This way it's proper for both 32-bit and 64-bit and you don't
need to worry about architecture. If you do need a signed
version, you can use ptrdiff_t.
Yup, that's what I
On Monday, 17 February 2014 at 07:17:06 UTC, Steve Teale wrote:
What is size_t for 64 bit?
Steve
Sorry parent.children is just a straightforward array
Sorry again - forget about it. I'd forgotten that D actually says
int is 32 bits, and ulong is 64, and size_t for a 64 bit machin
Why is it that with 32 bit compilation, int is 32 bits, but
apparently this convention is not followed in 64 bit compilation.
I have not installed the 64 bit compiler yet, but apparently
int len = parent.children.length+1;
provokes the following error
acomp.d(782): Error: cannot implicitly con
On Monday, 17 February 2014 at 07:15:20 UTC, Steve Teale wrote:
Why is it that with 32 bit compilation, int is 32 bits, but
apparently this convention is not followed in 64 bit
compilation.
I have not installed the 64 bit compiler yet, but apparently
int len = parent.children.length+1
On Tuesday, 11 February 2014 at 10:52:40 UTC, Tobias Pankrath
wrote:
The second naive solution would be to use readText and
splitLines.
That's the sort of thing I always do because then I understand
what's going on, and when there's a bug I can find it easily!
But then I'm not writing li
On Friday, 7 February 2014 at 07:43:05 UTC, Steve Teale wrote:
I was attempting to to build my app COMPO using a Makefile this
morning, and at first this worked to some extent, but after
some fiddling with compiler flags to make a release version
that then had problems, I reverted to my
I was attempting to to build my app COMPO using a Makefile this
morning, and at first this worked to some extent, but after some
fiddling with compiler flags to make a release version that then
had problems, I reverted to my original makefile as of yesterday.
That builds and links the app, but
On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote:
Here I feel like a beginner, but it seems very unfriendly:
import std.stdio;
struct ABC
{
double a;
int b;
bool c;
}
ABC[20] aabc;
void foo(int n)
{
writefln("n: %d, aabc.length: %d", n, aabc.length)
Here I feel like a beginner, but it seems very unfriendly:
import std.stdio;
struct ABC
{
double a;
int b;
bool c;
}
ABC[20] aabc;
void foo(int n)
{
writefln("n: %d, aabc.length: %d", n, aabc.length);
if (n < aabc.length)
writeln("A");
else
writeln("B");
}
void m
Is not needed because structs are inherently scope.
I'm sure experienced D programmers do this all the time when they want
something done on exit from a scope, but I never had, and maybe there are
others who haven't, particularly if coming from a C++ 'use classes for
everything' background.
im
Works like a charm, and it's so obvious a thing to try that I'm kicking myself.
Thanks
Steve
To bind variables, the MySQL api wants their addresses - in my tiny example
below, these are represented by the void*[].
If I just use something like setTarget in the example, it works fine, but then
when I try to set a bunch of them in one go I'm hosed because I can't get the
right addresses thro
Oh, so it is difficult after all! I thought it was just me.
So I am probably going to have to ask. Then the interesting question will be
which
way around will offend fewest people.
I have installed it as ISO, then have to ask US users if they would prefer
Letter
Size, or the other way round th
Looking at the documentation makes my head hurt, especially if I have consumed
some beer, when I am not pure and immutable.
Can anyone help me to understand how to determine what timezone the user has
selected to be his/hers.
Alternatively, let me explain my desire. When my program first runs, I
> I suppose it's the part of the spec you're about to write a patch for.
Twas at:
http://www.digitalmars.com/d/archives/digitalmars/D/
Template_instantiation_syntax_77507.html#N77507
> I suppose it's the part of the spec you're about to write a patch for.
I guess so. It was discussed on one of the forums back in October 2008. I
guess it got implemented but never made the documentation.
Which bit of the spec for template instantiation is it that allows the
last two lines of the following to compile and work?
import std.stdio;
struct A
{
int a;
}
template Thingie(T)
{
static if (is(T == int))
enum Thingie = 1;
else
enum Thingie = 0;
}
void main()
{
import std.array;
import std.range;
import std.stdio;
// A contrived input range
struct Sir
{
string s;
int pos;
bool empty() { return pos >= s.length; }
void popFront() { pos++; }
int front() { return s[pos]-'0'; }
}
int[] da = [1,2,3,4,5];
int[5] sa = [1,2,3,4,5];
void
sybrandy Wrote:
> On 02/03/2010 12:03 AM, Rainer Deyke wrote:
> > sybrandy wrote:
> >> 1) I use the current core.thread library and put all my messages in a
> >> buffer that the thread checks periodically, pulls off a new message, and
> >> then writes it to a file. There will be some work to make
Ary Borenszweig Wrote:
> Steve Teale wrote:
> > OK, so structs are a different beast in D than they are in C++. This
> > results in one of my most common pitfalls. I'll find myself writing:
> >
> > struct A
> > {
> >int a;
> >int b;
>
OK, so structs are a different beast in D than they are in C++. This results in
one of my most common pitfalls. I'll find myself writing:
struct A
{
int a;
int b;
}
A[] nameTooLong = ...;
foreach (whatever; thingie)
{
nameTooLong[whatever.whatever].a = whatever.x*3;
nameTooLong[what
Steven Schveighoffer Wrote:
> > This tells me that a string in D is a sequence of characters (whatever
> > that might mean) in memory, prefixed by a size_t length. Of course,
> > that's not to say there is no more to it, but the values for 'xtra'
> > don't give us much clue. If there was so
OK, so let's find out about strings. D does not have 'string' as a built in
type. It is just an alias for invariant(char[]). So what is it?
Well, you can find out quite a bit by compiling and running:
import std.stdio;
struct S
{
size_t len;
void* p;
int xtra;
}
void main()
{
strin
49 matches
Mail list logo