ntroduction of opEquals on a struct
History with no relationship to RC causes an error to show for RC.
Thanks
Dan
ng it
took me cull the code to the offending and I still don't
understand the error.
Thanks
Dan
d? Well, the only relation is their aggregation in
BSItem. Baffling.
Any suggestions appreciated.
Thanks
Dan
ics coupled with copy on write
semantics where needed. That approach, just does not seem worth
it without more systematic support for COW. Assuming postblits
are the issue, I don't understand why they are so hard to get
right.
Thanks
Dan
TDPL, or newsgroup) led you to this
solution and for how long will it be valid? Where can I read more
on it?
Thanks
Dan
welcome.
Also, an FYI to dpaste maintainer that the compiler service has
been unavailable for a while.
Thanks
Dan
hen on the first insert for a given key the hash is computed
just once. I believe this would have to be done at the level of
AssociativeArray and can not be done as a helper function, since
this set helper is still doing 3 hashes/lookups.
Thanks
Dan
hat is the reason for the difference
between unittest constants and module constants?
Thanks,
Dan
On Saturday, 9 February 2013 at 00:54:58 UTC, Andrej Mitrovic
wrote:
Feel free to file an enhancement request.
http://d.puremagic.com/issues/show_bug.cgi?id=9491
Hopefully that is clear.
?
- on linux is there a way, once in this state to provide any
information that would be helpful. strace during on a complete
run could help - but it is too late for that.
Thanks
Dan
specially with structs.
For structs we could use compile time reflection to provide
automatic efficient opCmp behavior. Section 3.1 here outlines a
way:
https://github.com/patefacio/d-help/blob/master/doc/canonical.pdf
Any comments appreciated.
Thanks
Dan
HOWEVER, when you get to th
ed a transitive copy.
Thanks
Dan
n not know the cost of postblit - or
copy construction if that were a future solution for structs.
Granted the no rvalue passing is a pain - but is it a big deal in
library/generic code?
Thanks,
Dan
{
if ( sMy point was, you can use compile time reflection to generate a
suitable opCmp that uses s.opCmp if it exists or does the long
version of two comparisons if not.
Thanks
Dan
ase
them out 1 or more years after successful implementation of copy
constructors
- Often the only purpose of the copy constructor is to do a deep
copy. This could easily be provided by the compiler or phobos.
Further, consider standardizing on the ".dup" and ".idup"
conventions for this purpose.
Thanks
Dan
:
/opt/compilers/dmd2/include/std/datetime.d(13542): Error:
Internal Compiler Error: CTFE literal cast(short)1
dmd: ctfeexpr.c:353: Expression* copyLiteral(Expression*):
Assertion `0' failed.
Thanks
Dan
b.com/patefacio/d-help/blob/master/d-help/opmix/mix.d
Thanks
Dan
On Tuesday, 19 March 2013 at 20:28:09 UTC, Jonathan M Davis wrote:
Those are what opEquals, opCmp, and toHash are for. It might
make sense to
define mixins which implement them for you (dealing with
whatever recursive
semantics are necessary), but using external functions for
those just isn't
matter how clever your external functions for comparing objects
or generating
hashes are, they're not going to work with the built-in AAs.
Any type which is
going to work with the built-in AAs must define opEquals and
toHash.
The above works with the built-in AAs.
Please offer an example.
Thanks
Dan
On Tuesday, 19 March 2013 at 23:13:19 UTC, Jonathan M Davis wrote:
On Tuesday, March 19, 2013 22:43:10 Dan wrote:
The above works with the built-in AAs.
Please offer an example.
It works because the outer type defines toHash. Without toHash,
the built-in
AAs won't work. If you'
On Wednesday, 20 March 2013 at 02:03:31 UTC, Jonathan M Davis
wrote:
We already get this. That's what == does by default. It's just
that it uses ==
on each member, so if == doesn't work for a particular member
variable and the
semantics you want for == on the type it's in, you need to
override
On Wednesday, 20 March 2013 at 02:54:23 UTC, Jonathan M Davis
wrote:
On Wednesday, March 20, 2013 03:48:38 Dan wrote:
On Wednesday, 20 March 2013 at 02:03:31 UTC, Jonathan M Davis
wrote:
> We already get this. That's what == does by default. It's
> just
> that it uses ==
&
.
Semantically deep equality is comfortable to me, but I would
imagine by now there is a fair amount of code that might rely on
a false result from opEquals if the members (slices, associative
arrays) are not bitwise the same.
Thanks
Dan
ed by the asset name.
Thanks,
Dan
import std.stdio;
struct Series {
// REQUIRED - need to have no aliasing
this(this) { data = data.dup; }
private double[] data;
}
struct Assets {
this(this) { itemToSeries.dup; }
// REQUIRED - want ctor to dup arg to ensure no aliasing
this(const(S
passed in, due to const transitivity. So that
requirement would ripple a change to all already const correct
instances to now need to flip to non-const. I'm looking for a
const correct solution. It should be doable ... I just have had
no luck with it.
Thanks
Dan
The following works and is the only way I have found to
initialize m.
Unfortunately it requires the cast.
Is this safe to do?
Is there a better way?
Is this a bug or are future features coming to clean it up?
Thanks
Dan
--
import std.stdio;
struct S {
this
work for associative arrays?
--
import std.exception;
struct S {
this(this) { x = x.dup; }
char[] x;
}
immutable S[string] aa;
static this() {
// now what
}
Thakns
Dan
On Wednesday, 20 March 2013 at 17:44:16 UTC, Ali Çehreli wrote:
In that case, brute force to the rescue (nc stands for
non-const): :)
this(const(Series[string]) source) {
auto nc_source = cast(Series[string])source;
itemToSeries = nc_source.dup;
}
Wow - that worked. Thanks! I h
)) )
Thanks
Dan
---
static void fromJson(ref AssetCategory assetType, Json src) {
string value = cast(string)src;
writeln("value is ",value);
final switch(value) {
case "Investment": { assetType = AssetCategory.Investment;
break; }
case "Prima
.__aggr2839
inout variables can only be declared inside inout functions
I can't seem to find any answers in the documentation. Anybody
could help me out?
thanks
dan
On Tuesday, 26 March 2013 at 19:35:51 UTC, Jacob Carlborg wrote:
I'll take a look. Which compiler and version are you using?
DMD64 D Compiler v2.062
ubuntu 64 bit
thanks!
On Monday, 29 April 2013 at 16:48:27 UTC, Jacob Carlborg wrote:
On 2013-04-29 14:45, Daniel Davidson wrote:
Ho do you debug D executables on mac os x in which debug
symbols are
available (preferably a setup that works in emacs with gdb or
gud-gdb)?
This thread seems to bring up the issue I am
When would you use in / out parameters instead of ref & const
keywords?
Thanks.
Structs can't easily be compared in C because of potential 'padding' inside the
struct which may (or may not) exist.
I was jut wondering if D somehow gets round this, and allows something like
memcmp to easily compare two structs.
array) may have
padding while others don't, or perhaps they have different size paddings.
Dan
Jarrett Billingsley Wrote:
> On Sun, May 17, 2009 at 3:55 PM, Dan wrote:
> > Structs can't easily be compared in C because of potential 'padding' inside
> > the
Jarrett Billingsley Wrote:
> On Sun, May 17, 2009 at 5:00 PM, Dan wrote:
> > That sounds great, and seems like yet another reason for me to switch to D
> > (other than the removal of header files which always seemed like a kludge).
> >
> > Just for the record though,
Is there a way to export static data from a DLL written in D?
I'd like to write some extension DLLs for a program, but they need to have
certain static data exports to be recognized. I've been able to export
functions, but no data appears in the export table of the DLL.
In MSVC 6 I can do it as
r compiles both the functions, even considering this I
assume it's not safe to use the old D1 way,
right?
Oh, and I've found the documentation really confusing on this metter.
Thanks,
Dan
eally hope this language will have a bright future.
Dan
That would be great.
Thanks again
assert (t3.x = 3.0);
return 0;
}
Thanks,
Dan
Hi,
it certainly helps. However I can't help myself, I still thinking that this is
the most complicated, hard read and to understand way to
overload operators. Maybe there is something I'm missing but I can't really see
the reason of all that. Other languages adopts a much
easier approach, for e
or pretty much everything, I'm just having hard time
with this operators overloading...
Thanks for you help guys,
Dan
I'm exploring D for embedded work as a nice alternative to C/C++ for the
32-bitters and am finding it has a nice set of features. But, what is
the best way handle memory mapped IO? I don't see volatile like in C.
Is writing asm {} the best way to ensure memory access?
Thanks,
Dan Olson
"Lars T. Kyllingstad" writes:
> On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:
>
>> I'm exploring D for embedded work as a nice alternative to C/C++ for the
>> 32-bitters and am finding it has a nice set of features. But, what is
>> the best wa
lure
>
> But these can't be passed to functions either, meaning I can't pass a Screen,
> Text, or Font wrapper around, all of which I use in my project!
It should be ok to pass A to a function for temporary use.
{
auto a1 = scoped!A();
dostuff(a1);
}
void dostuff(A a)
{
// .. but don't hang on to 'a' because dtor will be eventually called
}
Dan
bearophile writes:
>> Is this another compiler bug?
>
> The situation is nice:
>
> struct Foo1 {}
> struct Foo2 { int x; }
> const struct Foo3 { int* p; }
> struct Foo4 { int* p; }
> void bar1(Foo1 f) {}
> void bar2(Foo2 f) {}
> void bar3(Foo3 f) {}
> void bar4(Foo4 f) {}
> void main() {
> co
dennis luehring writes:
>> They're useful for testing:
>>
>> unittest {
>> int foo();
>> static assert (is(ReturnType!foo == int));
>> }
>
> and else? is it worth?
Don't class function declarations have the same issue? You can declare
but all you'll get is a link error. Unless there
al function reference through
the pointer.
Dan
given is:
i = i++;
None of this is stuff you'd normally want to write unless entering an
obfuscated programming contest, but Java's rules say if i = 42, 'i' will end up
still being 42.
Dan
I am running the dmd2 compiler on my Win7 64 bit machine and everything
appears to work except the -cov switch. i cannot seem to generate a .lst file.
any ideas?
thanks
dan mcleran
never mind, i got it. i had to pass the switches:
-D -unittest -cov
life is hard. it's even harder when you're dumb.
> foreach (m; __traits(allMembers, Metrics))
> {
> foo(mixin("Metrics." ~ m));
> }
> }
I'm exploring more and found there is also std.traits.EnumMembers. It's
a little simpler:
foreach (m; EnumMembers!Metrics))
{
foo(m);
}
And for number of members in enum Metrics
EnumMembers!Metrics.length
--
Dan
s flags this case, but I think it will go
unnoticed if your builds are done with something like ant and javac.
--
Dan Olson
on linux and don't know how it passes options to ld. You
can use objdump to show if a .gnu.hash section is being used. And on
older systems, the man page for ld won't list --hash-style.
--
Dan
mimocrocodil <4deni...@gmail.com> writes:
> I seen what sendmail actually changes they arguments of command line for nice
> output of "ps ax" command.
>
> May be it changes his argc/argv for this?
Yes. Some unix C programs, daemons usually, modify argv to change what ps
shows. It works with D
r the deprecated delete.
Dan
=-=-=
Sample:
import std.stdio;
class A
{
string name = "none";
void print() {writeln(name);}
}
void main()
{
A a = new A;
a.print(); // none
a.name = "xyzzy";
a.print(); // xyzzy
) was to
clean up but leave the thing in an initialized state. And because
clear() on dynamic arrays and other types seems to be be intended to
leave you with a valid and initialized object. Or is that not true?
Dan
I tried dmd -gc like on linux but gdb on OSX doesn't seem happy. Is
there a way to get the debuger to work with dmd on OSX?
Thanks,
Dan
Maybe you want Knuth's Literate Programming.
http://en.wikipedia.org/wiki/Literate_programming
Long ago it was only for pascal and C (web and cweb), but now I see
there is noweb that works with any programming language.
--
Dan
"evilrat" writes:
> On Thursday, 9 May 2013 at 20:33:17 UTC, bearophile wrote:
>> Brad Anderson:
>>
>>> a 64-bit Windows dmd build did not crash and here is the output.
>>
>> Thank you for the data point. So maybe the problem is only on 32 bit
>> Windows.
>>
>> Bye,
>> bearophile
>
> win8 dmd 2.0
I'm sending an exception from a worker thread to the owner thread
to be logged/printed. Using DMD64 D Compiler v2.064
http://dpaste.dzfl.pl/7c8b68bd
Using std.concurrency prevents me from passing a naked Exception.
So the owner receives either a shared or immutable Exception.
I can't format a sh
I just wanted to add that the "can't format immutable Exception"
also prevents me from doing this:
auto exception = receiveOnly!(immutable Exception)();
because receiveOnly creates a tuple which implements a toString
that uses indirectly uses formatObject. So I'm forced to use the
slightly mo
On Sunday, 22 December 2013 at 21:07:11 UTC, Charles McAnany
wrote:
Friends,
I'm writing a little molecular simulator. Without boring you
with the details, here's the gist of it:
struct Atom{
double x, vx;
double interaction(Atom a2){
return (a2.x-this.x)^^2; //more complicated
What is the difference between:
A
---
template Foo() {
int x = 5;
}
B
-
mixin template Foo() {
int x = 5;
}
The full example is from the first code sample on
http://dlang.org/template-mixin.html Both A and B compile and
when run, have the exact same output. So how is '
Check out the json module in vibe.d. Maybe copy it into your own
application (since it can't be used as a library, yet).
http://vibed.org/api/vibe.data.json/
https://github.com/rejectedsoftware/vibe.d
Found this:
http://forum.dlang.org/thread/ntuysfcivhbphnhnn...@forum.dlang.org#post-mailman.1409.1339356130.24740.digitalmars-d-learn:40puremagic.com
If what Jonathan says is true, then
http://dlang.org/template-mixin.html should be updated: s/mixin
template/template/
mixin template Foo(alias a){ alias Foo=a; }
pragma(msg, Foo!2); // error
template Bar(alias a){ alias Bar=a; }
pragma(msg, Bar!2); // ok
Perhaps I was unclear. What I meant:
What does 'mixin template' do that 'template' does not?
Where would I use 'mixin template'?
As far as I can tell, 'mixin
On Friday, 31 January 2014 at 06:24:27 UTC, Dan Killebrew wrote:
mixin template Foo(alias a){ alias Foo=a; }
pragma(msg, Foo!2); // error
template Bar(alias a){ alias Bar=a; }
pragma(msg, Bar!2); // ok
As far as I can tell, 'mixin template' does nothing new;
(besides fail to
// Next line will block execution until all tasks already in
queue finished.
// Almost all what I need, but new tasks will not be started.
taskPool.finish(true);
}
Are you sure TaskPool.finish isn't what you're looking for?
"Signals worker threads to terminate when the queue becomes
emp
It seems to me that worker threads will continue as long as
the queue isn't empty. So if a task adds another task to the
pool, some worker will process the newly enqueued task.
No. After taskPool.finish() no way to add new tasks to the
queue. taskPool.put will not add new tasks.
Then perhaps
A couple of questions:
1: Even though D has an automatic garbage collector, is one still
allowed to free the memory of a malloced array manually (using free
() ), to avoid pauses in the program?
2: One justification on the website for using automatic garbage
collection is how "allocated memory wi
).
Here's the usage:
```d
void main( ) {
uint[] nums = [1, 3, 2, 5, 1, 4, 2, 8];
auto sorted = _sort_array( nums );
import std.stdio;
writeln( "Input: ", nums );
writeln( "Output: ", sorted );
}
```
Thanks in advance for any info!
dan
On Sunday, 22 January 2023 at 07:33:01 UTC, evilrat wrote:
On Sunday, 22 January 2023 at 04:42:09 UTC, dan wrote:
I would like to write a function which takes an array as
input, and returns a sorted array without duplicates.
```d
private S[] _sort_array( S )( S[] x ) {
import
t the remaining 8 bytes to a fractional part, perhaps
ignoring the last 2 or 3 as not being significant.
But --- it seems like this kind of task may be something that d
already does, maybe with some constructor of a double or
something.
Thanks in advance for any suggestions.
dan
On Wednesday, 23 August 2023 at 03:24:49 UTC, z wrote:
On Tuesday, 22 August 2023 at 22:38:23 UTC, dan wrote:
Hi,
I'm parsing some files, each containing (among other things)
10 bytes said to represent an IEEE 754 extended floating point
number, in SANE (Standard Apple Numerical Enviro
runtime starts?) Although i would prefer to code in d, it would
be ok to do it in c.
This is on MacOS (Catalina) in case that makes a difference, and
i'm using dmd v2.104.0.
Thanks in advance for any clues.
dan
On Monday, 16 October 2023 at 03:33:55 UTC, Richard (Rikki)
Andrew Cattermole wrote:
On 16/10/2023 4:31 PM, dan wrote:
I suppose if i could figure out a way to make all other
modules depend on my module this would happen, but the module
which uses the variable i want to set is in some
already
On Monday, 16 October 2023 at 04:26:32 UTC, Paul Backus wrote:
On Monday, 16 October 2023 at 03:31:13 UTC, dan wrote:
I have some code that i would like executed before anything
else is.
The code is to set an environment variable which is used by a
library. I'm trying to find some w
constructor pragma.
(Now, i still think that when module initialization order is not
forced, it should be something a programmer or systems integrator
can choose, but i don't want to be too greedy.)
Thanks again for your help!!
dan
On Monday, 16 October 2023 at 18:57:45 UTC, bachmeier wrote:
On Monday, 16 October 2023 at 18:28:52 UTC, dan wrote:
(Now, i still think that when module initialization order is
not forced, it should be something a programmer or systems
integrator can choose, but i don't want to be too g
But i would like to be able to do this without knowing the
expansion of pi, or writing too much code, especially if there's
some d function like writeAllDigits or something similar.
Thanks in advance for any pointers!
dan
On Wednesday, 9 October 2019 at 10:54:49 UTC, David Briant wrote:
On Tuesday, 8 October 2019 at 20:37:03 UTC, dan wrote:
I have a double precision number that i would like to print
all significant digits of, but no more than what are actually
present in the number. Or more exactly, i want to
On Thursday, 10 October 2019 at 22:44:05 UTC, H. S. Teoh wrote:
On Thu, Oct 10, 2019 at 09:13:05PM +, Jon Degenhardt via
Digitalmars-d-learn wrote:
On Thursday, 10 October 2019 at 17:12:25 UTC, dan wrote:
> Thanks also berni44 for the information about the dig
> attribute, Jon
>
te/writeln apparatus?
My only real requirement is that it be something really easy to
do.
Thanks in advance for any pointers.
dan
On Saturday, 2 May 2020 at 02:29:43 UTC, H. S. Teoh wrote:
On Sat, May 02, 2020 at 02:22:42AM +, dan via
Digitalmars-d-learn wrote:
I'm looking for a function something like writeln or write,
but instead of writing to stdout, it writes to a string and
returns the s
On Saturday, 2 May 2020 at 02:49:04 UTC, Steven Schveighoffer
wrote:
On 5/1/20 10:40 PM, dan wrote:
On Saturday, 2 May 2020 at 02:29:43 UTC, H. S. Teoh wrote:
On Sat, May 02, 2020 at 02:22:42AM +, dan via
Digitalmars-d-learn wrote:
[...]
[...]
import std.format : format;
string
On Saturday, 2 May 2020 at 10:36:47 UTC, Ali Çehreli wrote:
On 5/1/20 7:40 PM, dan wrote:> On Saturday, 2 May 2020 at
02:29:43 UTC, H. S. Teoh wrote:
>> On Sat, May 02, 2020 at 02:22:42AM +, dan via
Digitalmars-d-learn
>> wrote:
>>> I'm looking for a function so
ge for it, but man i could sure be wrong.)
Thanks in advance for any info!
dan
Are there any d compilers that run natively on the Mac Mini with
an M1 chip?
If so, does anybody here have any experience with them that can
be shared?
If not, and your machine is a mac mini, how would you go about
programming in d on it?
TIA for any info!
On Friday, 26 March 2021 at 21:54:20 UTC, rikki cattermole wrote:
On 27/03/2021 10:51 AM, dan wrote:
Are there any d compilers that run natively on the Mac Mini
with an M1 chip?
If so, does anybody here have any experience with them that
can be shared?
If not, and your machine is a mac
just what methods Object
implements, and what those methods do.
Thanks in advance for any clues, or a pointer to page 1 of the
manual if it's there and i'm just being dense.
dan
On Tuesday, 7 November 2017 at 21:32:26 UTC, Adam D. Ruppe wrote:
On Tuesday, 7 November 2017 at 21:25:00 UTC, dan wrote:
I looked in my distribution's object.d (debian stretch, gdc, in
Did you import std.stdio in the file?
If so, it is calling the std.stdio.write on the object (th
the transition. Can anyone here
who has already made that transition tell me how smoothly it
went? Any major unexpected problems? Advice?
thanks!
Dan
Thanks everyone for taking the time to respond!
@Lobo,
Start using D now. It's not all or nothing so you don't have to
give up on C++. I have several projects that contain both C++
and D intermixed.
Using both does seem like a good way to transition. I could
combine the strengths of D with
"no" (the only
relevant type qualifiers are private, package, protected, public,
and export, and none seem appropriate).
(This effect could be simulated by making my_var into a function,
but i don't want to do that.)
TIA for any info!
dan
Thanks Vit, Meta, and Yuxuan for your speedy help!
So 3 pieces to put together, function, const, and @property (and
i guess final for protection against subclasses).
On Monday, 23 May 2016 at 07:03:08 UTC, chmike wrote:
On Saturday, 21 May 2016 at 17:32:47 UTC, dan wrote:
(This effect could be simulated by making my_var into a
function, but i don't want to do that.)
May I ask why you don't want to do that ?
In D you can call a function wi
piled language wouldn't want to provide this
feature. (But the php interpreter, whatever else is good or bad
about it, does let you write 'new self(...)' and does the right
thing with it.)
TIA for any clues.
dan
On Sunday, 29 May 2016 at 00:28:13 UTC, Mithun Hunsur wrote:
On Sunday, 29 May 2016 at 00:14:17 UTC, dan wrote:
Is there a standard alias for a class name inside class code?
Something like 'this' referring to a class instance, but
referring instead to the class itself?
[...]
t
101 - 200 of 236 matches
Mail list logo