from it. The two types may have absolutely nothing to do with each other.
It's closer to constructing a value of one type from a value of another type
than treating one like the other.
So, as Bearophile says, the purposes of casting and std.conv.to are very
different.
- Jonathan M Davis
to worry about the built-in cast accidentally being used instead of
your user-defined opCast if you screwed up - e.g. by declaring
int opcast(T : int)() const { .. }
Though in many cases, the compiler will still catch that for you (not all
though).
- Jonathan M Davis
to use command-line switches and getopt would help
some, but you still have to deal with the error messages yourself. Creating
the Person is the easy part.
- Jonathan M Davis
,
since it's frequently desirable to return slices of them, and scope (and
therefore in) would prevent that. It's useful in some instances (particularly
with delegates), but I'd use in _very_ sparingly. It's almost always more
trouble than it's worth IMHO.
- Jonathan M Davis
be
left up to the compiler to optimize or not as it sees appropriate.
- Jonathan M Davis
it everywhere is painful, but once you switch everything over you get
the benefits.
That would destroy slicing. I'm firmly of the opinion that scope should be used
sparingly.
- Jonathan M Davis
.
There already is such an overload in HEAD.
- Jonathan M Davis
On Wednesday, February 08, 2012 09:35:28 H. S. Teoh wrote:
On Wed, Feb 08, 2012 at 08:32:32AM -0800, Jonathan M Davis wrote:
[...]
Except that char[] is _not_ an array of characters. It's an array of
code units. There is a _big_ difference. Not even dchar[] is an array
of characters
On Wednesday, February 08, 2012 17:52:17 Manfred Nowak wrote:
Jonathan M Davis wrote:
thanks to how unicode works
This does not mean, that the data structure representing a sequence of
letters has to follow exactly the working you cited above. That
data structure must only enable
();
auto c = cast(Derived)b;
assert(c !is null);
Casting is definitely the way that you're supposed to do it. If the cast
results in null, then the class is _not_ of the type that you cast to. e.g.
if(auto d = cast(Derived) b)
//do stuff with d
- Jonathan M Davis
, and
it would work.
Normally, it's considered good practice to give modules names which are all
lowercase (particularly since some OSes aren't case-sensitive for file
operations). Renaming your module to foo should fix your problem.
- Jonathan M Davis
On Thursday, February 09, 2012 14:45:43 bearophile wrote:
Jonathan M Davis:
Normally, it's considered good practice to give modules names which are
all lowercase (particularly since some OSes aren't case-sensitive for
file operations).
That's just a fragile work-around for a module
it (it's been a while since I programmed in C#). I believe
that the one public class per file requirement is something that Java
introduced and which is not common among programming languages in general.
- Jonathan M Davis
exposure to IMHO.
- Jonathan M Davis
they might
be virtual when mixed into classes - I'm not sure). And if template mixins
aren't virtual, then _both_ mixins should be illegal, since Object already
have a virtual toString in it.
Regardless, I don't see how you could think that your code would be legal.
- Jonathan M Davis
the generic implementation. So, I would say that
it's safe to say that you can't use copy to copy overlapping arrays. I'm not
even sure it's a good idea to use overlapping ranges. I haven't dealt with
output ranges enough to say without studying up on them again.
- Jonathan M Davis
M Davis
prefer that the alias name were used if
the variable in question was declared with the alias name rather than the
original, but that's just not how it works at this point.
- Jonathan M Davis
On Saturday, February 11, 2012 23:59:39 bearophile wrote:
Jonathan M Davis:
aliases are always replaced with the original and you never see the
aliased
name in the compiler output. It's only for the source. Now, that's not
entirely a good thing. I'd actually prefer that the alias name
On Sunday, February 12, 2012 13:00:16 Trass3r wrote:
dmd simply doesn't keep those information about aliases.
Exactly.
- Jonathan M Davis
difference? We're
trying to not have any ASCII-only string stuff.
- Jonathan M Davis
to right, but I don't believe that he's done it yet, and it
may or may not ever happen.
- Jonathan m Davis
On Monday, February 13, 2012 19:47:03 Artur Skawina wrote:
On 02/13/12 18:57, Jonathan M Davis wrote:
On Sunday, February 12, 2012 10:07:52 Ali Çehreli wrote:
Related question: Does D define the order of evaluation in an
expression
like
foo() ~ bar()
Or is it unspecified as in C
On Monday, February 13, 2012 14:08:16 bearophile wrote:
Jonathan M Davis:
Do you have data to backup that there is a significant speed difference?
I have just written a small benchmark, it contains both the URL to the test
data and the timings I am seeing on a slow PC. If your PC is faster
Walter wants to make
it so that function arguments are always evaluated left-to-right, but until
that happens, I wouldn't bet on foo() ~ bar() being guaranteed to have foo
called before bar, even it's supposed to be.
- Jonathan M Davis
calling op!~(foo(), bar()) would be.
- Jonathan M Davis
are relatively minor in comparison to fixing bugs. The source is open
on github for anyone to hack at and submit pull requests if they want to
though.
- Jonathan M Davis
the odds of your code being buggy (due
to what is likely a compiler bug) are too high.
- Jonathan M Davis
that unittest blocks get compiled into each individual
template instantiation is something that anyone writing templated types should
know.
- Jonathan M Davis
to not really a quicksort
however my missing the point still stands. I still prefer arrays
over S-lists anyway, how else do I efficiently implement a heap?
Orphan tears. It's the only way to go.
- Jonathan M Davis
On Wednesday, February 15, 2012 17:32:07 Daniel Murphy wrote:
Jonathan M Davis jmdavisp...@gmx.com wrote in message
news:mailman.306.1329166430.20196.digitalmars-d-le...@puremagic.com...
Ideally perhaps, but I expect that that's not true, because operator
overloading is done via lowering
with dates and
times is to put the 0 in front of single digit numbers. You'll note that in
the string representations, you _have_ to (per the ISO standard). So, I ended
up doing it with the integer literals without thinking about it.
- Jonathan M Davis
surprised if Walter agreed to do that. It'll just permanently
stay an error like it is now.
- Jonathan M Davis
On Thursday, February 16, 2012 00:38:10 Stewart Gordon wrote:
On 15/02/2012 16:41, Jonathan M Davis wrote:
snip
They're not left over at all, and they have nothing to do with octal.
snip
They are something to do with octal: because in D an integer literal
beginning with 0 is defined
without having
to make it so that interface functions can have default implementations.
- Jonathan M Davis
they can be virtual, unlike templated
functions. I don't know though. It's not something that I've really had to
worry about - particularly since so few of my D programs need classes, let
alone interfaces (because most of my D programs are small).
- Jonathan M Davis
for a derived class when you only override
some of them). But I haven't tried it, so I don't know.
- Jonathan M Davis
It seems rather strange to me. I'd expect the foreach_reverse to
go over the array from the end to the beginning, and when I
remove stuff from it, it shouldn't be a problem. But apparently
it is.
I don't believe that removing elements from an AA while iterating over it is
safe.
- Jonathan M Davis
ways to do this?
That's the way that I'd do it.
- Jonathan M Davis
On Thursday, February 16, 2012 00:38:10 Stewart Gordon wrote:
On 15/02/2012 16:41, Jonathan M Davis wrote:
snip
They're not left over at all, and they have nothing to do with octal.
snip
They are something to do with octal: because in D an integer literal
beginning with 0 is defined
e = range.front;
}
}
return cast(ElementType!R)e;
}
- Jonathan M Davis
puns intended). Does anyone know how to get
this to work?
Template functions are non-virtual. You can't derive from them. If you want
the derived classes to have the same functions, you must redefine them in the
derived class.
- Jonathan M Davis
, concrete functions. So, you could alias an
specific instantiation of a templated function, but not the templated function
as a whole. e.g.
alias get!int getInt;
works, but
alias get getVal;
doesn't.
- Jonathan M Davis
it could work.
- Jonathan M Davis
On Sunday, February 19, 2012 12:34:07 Jacob Carlborg wrote:
Template functions are non-virtual. You can't derive from them. If you
want
the derived classes to have the same functions, you must redefine them in
the derived class.
- Jonathan M Davis
Yeah, but isn't that an overload
the documentation says?
Regardless, you can open either a bug report or an enhancement request for it.
I would not expect it to change otherwise.
- Jonathan M Davis
should read this article on arrays:
http://www.dsource.org/projects/dcollections/wiki/ArrayArticle
It should help you understand how they work, which will hopefully help you
avoid some headaches.
- Jonathan M Davis
that and see if it fixes
it.
- Jonathan M Davis
' overload set. It shouldn't matter whether the derived class is
adding overloads or just overriding a subset of the base class' overloads.
If the compiler devs really think that it's an enhancement request, then they
can change it, but it definitely looks like a bug to me.
- Jonathan M Davis
.
- Jonathan M Davis
that, it could be
considered either both an override and an overload or just an overload. And
apparently the override attribute only applies to exact overloads.
- Jonathan M Davis
advise against having a container which is a range. It's
a _bad_ idea which is only going to cause you trouble.
- Jonathan M Davis
On Wednesday, February 22, 2012 16:25:09 Ali Çehreli wrote:
On 02/22/2012 03:59 PM, Jonathan M Davis wrote:
On Wednesday, February 22, 2012 15:40:41 Ali Çehreli wrote:
On 02/22/2012 03:16 PM, Blake Anderton wrote:
With an array the above tests work (I assume because each
operation
, and if you make
it return true, then your program will work.
- Jonathan M Davis
On Wednesday, February 22, 2012 18:22:59 H. S. Teoh wrote:
On Wed, Feb 22, 2012 at 09:08:24PM -0500, Jonathan M Davis wrote:
[...]
I don't remember _exactly_ how the free function version of opEquals lined
out (I believe that TDPL explains it),
Yes, TDPL lays out the entire function
On Thursday, February 23, 2012 21:17:46 mist wrote:
But is there any way to actually say D compiler that I want this
function to accept only pure delegates?
Mark the delegate type that it accepts as pure.
- Jonathan M Davis
after the unit tests
have been run.
It's not uncommon for people to do something like this so that they can have
the unit tests run without running their actual program:
version(unittest) void main() {}
else void main()
{
//Your normal main...
}
- Jonathan M Davis
you typically do when you write the
code).
- Jonathan M Davis
very well be further problems due to what the IDE is doing (such as
not doing a full recompile when you enable -unittest), but the unit tests
won't print anything out on success regardless unless you use print statements
in them.
- Jonathan M Davis
that I've never used an IDE with D, so I can't really help
with IDE-specific problems. It does sound like your not running the right
binary though (like maybe you ended up with two of them, and it's the old one
which is being run). I can only guess though.
- Jonathan M Davis
similar.
I would have thought so though, because otherwise it would have to hardcode
the paths and linker options for Phobos. But maybe it does hardcode them. I
don't know.
- Jonathan M Davis
://dlang.org/function.html
http://dlang.org/template.html
- Jonathan M Davis
On Thursday, February 23, 2012 21:38:27 Jonathan M Davis wrote:
On Friday, February 24, 2012 05:22:58 Sarath Kumar wrote:
Hi,
Is there an equivalent to vfprintf(const char *fmt, , va_list ap) in D?
If you're dealing with C variadics, then your going to need to use C
functions. D
another version of
Phobos, you're going to need to build it against GDC's version of druntime.
- Jonathan M Davis
On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
This is useful:
struct S{
@disable enum init = 0;
}
I thought that the way that you were supposed to do that was
@disable this();
- Jonathan M Davis
On Saturday, February 25, 2012 17:54:44 H. S. Teoh wrote:
On Sun, Feb 26, 2012 at 12:23:47AM +0100, Alex Rønne Petersen wrote:
On 26-02-2012 00:18, Jonathan M Davis wrote:
On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
This is useful:
struct S{
@disable enum init
On Sunday, February 26, 2012 13:15:51 Alex Rønne Petersen wrote:
On 26-02-2012 12:53, Jonathan M Davis wrote:
On Sunday, February 26, 2012 12:48:06 Timon Gehr wrote:
On 02/26/2012 12:18 AM, Jonathan M Davis wrote:
On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
This is useful
that I am not aware of. :))
Yeah. In theory, switch statements can be optimized better than if-else
chains, and eventually I'd fully expect that dmd would do that, but right now,
I don't think that they really are. You'd have to look at the generated
assembly though to be sure though.
- Jonathan M
property), and the differences between null and
empty are largely ignored for arrays anyway.
- Jonathan M Davis
On Monday, February 27, 2012 23:55:39 Dmitry Olshansky wrote:
On 27.02.2012 23:18, Jonathan M Davis wrote:
On Monday, February 27, 2012 10:55:12 Ali Çehreli wrote:
On 02/27/2012 08:29 AM, Tyler Jameson Little wrote:
I didn't want to do subclassing, because my parser is a state-machine
function() {} instead.
If I read the spec correctly, one must use the 'function' keyword.
TDPL says that it's inferred, and I believe that work was recently done in
improving the compiler's ability to infer it. So, in this case, the spec is
almost certainly wrong.
- Jonathan M Davis
want to distinguish between null and empty without having to
worry about all of the little details, then you can use std.typecons.Nullable.
- Jonathan M Davis
that in the condition rather than using the
return value directly.
- Jonathan M Davis
. isSomeFunction!(writeln!string))),
or you need to just test that particular call works (e.g.
is(typeof(writeln(arg. The second is probably better, since that's
generally what you really care about - is it compilable with the given set of
arguments.
- Jonathan M Davis
do. It
will continue to insist on lvalues for all ref parameters, const or otherwise.
- Jonathan M Davis
) is not callable
using argument types (E3)
// Error: cast(const(S2))S2(1) is not an lvalue
enum E3 : S2 {
a = S2(1),
b = S2(2)
}
void main() {
}
So E3 is passed as the parameter to S2.opCmp..?
http://d.puremagic.com/issues/show_bug.cgi?id=4423
- Jonathan M Davis
On Thursday, March 01, 2012 00:17:55 Robert Clipsham wrote:
Just as a side note, -profile doesn't work with multi-threaded
applications, so using some other profiler would probably be a better
bet anyway.
It doesn't work with 64-bit programs either.
- Jonathan M Davis
On Wednesday, February 29, 2012 20:25:35 bearophile wrote:
Do you know why std.array.Appender defines a put method instead of
overloading the ~= operator?
put is a function on output ranges, and Appender is an output range.
- Jonathan M Davis
On Wednesday, February 29, 2012 20:53:04 Jonathan M Davis wrote:
On Wednesday, February 29, 2012 20:25:35 bearophile wrote:
Do you know why std.array.Appender defines a put method instead of
overloading the ~= operator?
put is a function on output ranges, and Appender is an output range
On Wednesday, February 29, 2012 21:23:54 bearophile wrote:
Jonathan M Davis:
put is a function on output ranges, and Appender is an output range.
Also, given that it doesn't define ~ (and it wouldn't really make sense
for it to), it would be very weird IMHO to define ~=.
I don't
such an
implementation, and there's a decent chance that it's going to make it into
Phobos.
So, I'm not sure that treating Appender as an array is really a good idea in
the first place. If you want the truly generic approach, then treat is an
output range.
- Jonathan M Davis
, master only ever
gets updated when the main repository gets updated, and you always have a
clean version which matches the main repository.
- Jonathan M Davis
a
class at compile and have it persist to runtime). You need to actually
initialize a SysTime before using it. So, using the init value of struct which
has a SysTime as a member probably isn't a great idea.
- Jonathan M Davis
of
screwing up the cast if you use std.conv.to. So, defining an opCast is fine,
but
it should probably be used with std.conv.to rather than directly.
- Jonathan M Davis
to be doing should be plenty as long as an instance of the struct remains in
the D code - as opposed to passing it to the C code and then not having it in
the D code anymore, which would be no better than just passing the char* to
the C code without keeping a reference to it).
- Jonathan M Davis
trying to call it without giving the type.
- Jonathan M Davis
On Friday, March 02, 2012 14:47:00 Graham Fawcett wrote:
On Thu, 01 Mar 2012 17:16:59 -0500, Jonathan M Davis wrote:
If you make changes in a branch and want them on top of what's in
master, then do
git-rebase master
While git-rebase may be available on your system, I think
on purpose that all strings are treated as ranges of
dchar.
- Jonathan M Davis
)
and use file/line in there. The exception consturctors
do this, so you can
throw new Exception(msg, file, line);
and get it passed on.
I think __LINE__ is size_t not int
Yes, it's size_t.
- Jonathan M Davis
On Saturday, March 03, 2012 18:38:44 Timon Gehr wrote:
On 03/03/2012 09:40 AM, Jonathan M Davis wrote:
... but operating on
code points is _far_ more correct than operating on code units. It's also
more efficient.
[snip.]
No, it is less efficient.
Operating on code points is more
to, but it operates or ranges of dchar by default,
because it's more correct.
- Jonathan M Davis
On Saturday, March 03, 2012 13:46:16 Ali Çehreli wrote:
On 03/03/2012 01:42 PM, H. S. Teoh wrote:
On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote:
[...]
The current solution encourages correct usage (or at least usage which
is closer to correct, since it still isn't
On Saturday, March 03, 2012 13:46:16 Ali Çehreli wrote:
On 03/03/2012 01:42 PM, H. S. Teoh wrote:
On Sat, Mar 03, 2012 at 12:42:53PM -0800, Jonathan M Davis wrote:
[...]
The current solution encourages correct usage (or at least usage which
is closer to correct, since it still isn't
days). I'm also seeing int used in Derelict,
pspemu, plot2kill and dwt2.
It's a common error to use int where size_t should be used. Using int when
dealing with __LINE__ is just one case of that. It didn't start actually
causing compilation errors until we go 64-bit dmd though.
- Jonathan M Davis
override for fields.
Variables can't be polymorphic, and it wouldn't make sense for them to be.
Overidding is done to change behavior.
By the way, I wouldn't rely on much that ideone says about D at this point.
It's still on version 2.042 of dmd, whereas the latest release is 2.058.
- Jonathan M
that.
- Jonathan M Davis
it to a C string, which means that it needs to be zero-
terminated. The only strings in D which are automatically zero-terminated are
string literals.
- Jonathan M Davis
On Monday, March 05, 2012 11:32:39 Jesse Phillips wrote:
On Sunday, 4 March 2012 at 20:25:40 UTC, Jonathan M Davis wrote:
By the way, I wouldn't rely on much that ideone says about D at
this point.
It's still on version 2.042 of dmd, whereas the latest release
is 2.058.
- Jonathan M
) != typeid(B));
assert(typeid(obj) == typeid(C));
}
- Jonathan M Davis
incremental compilation, then use -c to generate object files
that you link together when you create the actual executable.
- Jonathan M Davis
1 - 100 of 4227 matches
Mail list logo