On 07/04/2016 11:07 PM, Miguel L wrote:
> struct A
> {
> int x;
> int y;
> }
> would be the best way to get an array of x or y component of my_array?
The simplest is to pick the element by std.algorithm.map:
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
struct A
Hello
I would like advice in the most elegant way for doing this in D:
I have something like this:
struct A
{
int x;
int y;
}
A[] my_array;
And I would need something like this:
assert( my_array[0..n].x == [ my_array[0].x, my_array[1].x, ...
my_array[n-1].x ]);
assert( my_array[0..n].y == [
On Tuesday, 5 July 2016 at 03:32:25 UTC, WhatMeWorry wrote:
Just learning Linux. Got my first vibe/dub project which dies
at:
Compiling diet template 'index.dt'...
Linking...
/usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
I downloaded DUB's d2sqlite3 and built
Hi ("Grüss Gott")
I like the asynchronous events in Javascript.
Is something similar possible in D?
Found Dragos Carp's asynchronous library
(https://github.com/dcarp/asynchronous).
Are there any more integrated (in Phobos/in D) ways to work
asynchronously?
An example: One server ask a
On 07/04/2016 08:32 PM, WhatMeWorry wrote:
> /usr/bin/ld: cannot find -lsqlite3
> collect2: error: ld returned 1 exit status
I had the same issue when building Button with dub on Ubuntu 16.04. My
hack was to create the following symlink to the already existing
libsqlite3.so.0:
sudo ln -s
On Tuesday, 5 July 2016 at 07:33:40 UTC, Ali Çehreli wrote:
On 07/04/2016 11:07 PM, Miguel L wrote:
> [...]
> [...]
my_array?
The simplest is to pick the element by std.algorithm.map:
[...]
Thank you Ali, that works.
On the same subject, could it be possible to implement some class
or
On Tuesday, 5 July 2016 at 19:34:48 UTC, Andrew Edwards wrote:
On Tuesday, 5 July 2016 at 19:25:50 UTC, WebFreak001 wrote:
On Tuesday, 5 July 2016 at 19:14:32 UTC, Andrew Edwards wrote:
There is on --config=client for the current version of dub so
I went to the location of the source for
On Tuesday, 5 July 2016 at 19:58:03 UTC, Andrew Edwards wrote:
On Tuesday, 5 July 2016 at 19:43:02 UTC, WebFreak001 wrote:
On Tuesday, 5 July 2016 at 19:34:48 UTC, Andrew Edwards wrote:
It's more than that. Now, it fails because it can't find DMD.
As you can see in the build.bat from DCD it
On Tuesday, 5 July 2016 at 19:58:03 UTC, Andrew Edwards wrote:
On Tuesday, 5 July 2016 at 19:43:02 UTC, WebFreak001 wrote:
On Tuesday, 5 July 2016 at 19:34:48 UTC, Andrew Edwards wrote:
It's more than that. Now, it fails because it can't find DMD.
As you can see in the build.bat from DCD it
On Tuesday, 5 July 2016 at 18:16:31 UTC, Charles Hixson wrote:
I've been reading std.datetime documentation backwards and
forwards, but if the information is there, I've been missing it.
How do I get the current time as a long?
Clock.currTime() returns a SysTime, and while currently I can
On 07/05/2016 08:16 PM, Charles Hixson via Digitalmars-d-learn wrote:
What I'm looking for is the opposite of the "FromUnixTime" function.
That would be the "toUnixTime" method then, I suppose.
https://dlang.org/phobos/std_datetime.html#.SysTime.toUnixTime
On Tuesday, July 05, 2016 11:43:32 Jonathan M Davis via Digitalmars-d-learn
wrote:
> But if what you want is a time_t, and you don't want to deal with SysTime,
> there's no point in using std.datetime. Just use core.time to call C's time
> function.
Actually, I should qualify this. I keep
On Tuesday, July 05, 2016 18:25:17 John via Digitalmars-d-learn wrote:
> On Tuesday, 5 July 2016 at 18:16:31 UTC, Charles Hixson wrote:
> > I've been reading std.datetime documentation backwards and
> > forwards, but if the information is there, I've been missing it.
> >
> > How do I get the
On Tuesday, 5 July 2016 at 19:25:50 UTC, WebFreak001 wrote:
On Tuesday, 5 July 2016 at 19:14:32 UTC, Andrew Edwards wrote:
[...]
It fails on installing DCD. On the installation.bat just select
2,3 and get prebuilt DCD binaries from the project page or
build them yourself.
I could maybe
On Tuesday, 5 July 2016 at 19:14:32 UTC, Andrew Edwards wrote:
I cloned the package and ran install.bat.
The result is
$ dub build --build=release --config=client
Performing "release" build using ldc2 for x86.
experimental_allocator 2.70.0-b1: building configuration
"library"...
Using Visual
On Tuesday, 5 July 2016 at 08:24:43 UTC, O/N/S wrote:
Hi ("Grüss Gott")
I like the asynchronous events in Javascript.
Is something similar possible in D?
Found Dragos Carp's asynchronous library
(https://github.com/dcarp/asynchronous).
Are there any more integrated (in Phobos/in D) ways to
Hello,
I've been working on some kind of allocator using a dynamic array
as a memory pool. I used emplace to allocate class instances
within that array, and I was surprised to see I had to use
GC.addRange() to avoid the GC to destroy stuff referenced in that
array.
Here's a chunk of
On Tuesday, 5 July 2016 at 11:02:11 UTC, Satoshi wrote:
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
Property functions are used wrong by a compiler when it needs
to get and set a value at the same time:
[...]
Try
@property ref int value() {
return value_;
}
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
Property functions are used wrong by a compiler when it needs
to get and set a value at the same time:
[...]
Try
@property ref int value() {
return value_;
}
Am Tue, 5 Jul 2016 00:37:54 -0700
schrieb Ali Çehreli :
> On 07/04/2016 08:32 PM, WhatMeWorry wrote:
>
> > /usr/bin/ld: cannot find -lsqlite3
> > collect2: error: ld returned 1 exit status
>
> I had the same issue when building Button with dub on Ubuntu 16.04.
> My hack
Am 05.07.2016 um 00:41 schrieb Rene Zwanenburg:
> On Monday, 4 July 2016 at 19:22:52 UTC, Johannes Loher wrote:
>> This looks really nice, but I have several occurences of this, with
>> different arrays (and lengths), so i would need to create several of
>> those structs. But it looks really clean
ttt.d
import std.string;
void main() {
lastIndexOf("aa","bb");
}
rdmd ttt.d
compiles successfully without any errors or warnings
rdmd -dw ttt.d
compiles successfully without any errors or warnings
rdmd -de ttt.d
/usr/include/dmd/phobos/std/string.d(1239): Error: template
On 07/05/2016 12:47 PM, Jack Applegame wrote:
ttt.d
import std.string;
void main() {
lastIndexOf("aa","bb");
}
rdmd ttt.d
compiles successfully without any errors or warnings
rdmd -dw ttt.d
compiles successfully without any errors or warnings
rdmd -de ttt.d
On Tuesday, 5 July 2016 at 12:43:14 UTC, ketmar wrote:
On Tuesday, 5 July 2016 at 10:04:05 UTC, Claude wrote:
So here's my question: Is it normal???
yes. `ubyte` arrays by definition cannot hold pointers, so GC
doesn't bother to scan 'em.
Ah ok. I tried using void[size] static array and it
On Tuesday, 5 July 2016 at 13:37:50 UTC, ketmar wrote:
if this minor thing blocks you from using D... alas. otherwise,
just make a workaroung and keep going. *eventually* this will
be fixed, but you'd better don't wait for it.
No, this issue doesn't block me from using D. I'm asking because
On Tuesday, 5 July 2016 at 13:37:50 UTC, ketmar wrote:
you *can* workaround this limitation for now. it won't be the
cleanest code in the world, but you can do it. hint: alias this
+ returning temporary struct with pointer.
Of course, I can. I have been creating a lot of such workarounds
On Tuesday, 5 July 2016 at 13:48:50 UTC, ag0aep6g wrote:
Something is also going wrong in dmd. There should be a
deprecation message.
Exactly.
On Tuesday, 5 July 2016 at 12:45:33 UTC, ketmar wrote:
Is there a chance, that this weird behavior will be fixed in
the near future? What can I do to help fix it?
almost as much as you can expect snowfall in hell.
Why do you have so pessimistic opinion? Is D a perspective
language to learn
D is being used productively by some companies, so I guess we can call it
production-ready. This doesn't meant there are not rough corners. The
language is being actively developed, and I see that some work is being
done on those rough corners. However, keep in mind that:
1) Maybe what you
On Tuesday, 5 July 2016 at 12:34:20 UTC, Johannes Loher wrote:
I tried this, but it does not work correctly with slices.
The length of a slice is a runtime value, which is why it can't
be used to set static array size. What were you trying to
achieve? Avoid copying the input arrays, or
On Tuesday, 5 July 2016 at 10:04:05 UTC, Claude wrote:
So here's my question: Is it normal???
yes. `ubyte` arrays by definition cannot hold pointers, so GC
doesn't bother to scan 'em.
On 7/2/16 8:10 AM, qznc wrote:
I want to implement some caching for HTTP GET requests. Basically a map
of URL to content. A cache needs some additional meta data (size, age,
etc).
There seem to be two basic data structures available: Associative array
(AA) or red black tree (RBT).
With AA
On Tuesday, 5 July 2016 at 13:14:29 UTC, zodd wrote:
Why do you have so pessimistic opinion?
it is realistic.
Is D a perspective language to learn or it's stagnating and
never be production ready?
what do you want here: "non-stagnating" or "production ready"? D
is "production ready", and
On 7/5/16 6:52 AM, zodd wrote:
Is there a chance, that this weird behavior will be fixed in the near
future? What can I do to help fix it?
Properties do not support read-modify-write operations. You can return a
reference, or return a wrapper type to enable the operations you want.
D does
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
It's a very inconvenient. Why don't just call a getter and then
a setter functions in such cases?
'cause property specs aren't even finalized yet.
Is there a chance, that this weird behavior will be fixed in
the near future? What can I do
On Tuesday, July 05, 2016 11:16:31 Charles Hixson via Digitalmars-d-learn
wrote:
> What I'm looking for is the opposite of the "FromUnixTime" function.
SysTime has toUnixTime, which is right above fromUnixTime in the
documentation.
But if what you want is a time_t, and you don't want to deal
I cloned the package and ran install.bat.
The result is
$ dub build --build=release --config=client
Performing "release" build using ldc2 for x86.
experimental_allocator 2.70.0-b1: building configuration
"library"...
Using Visual Studio: C:\Program Files (x86)\Microsoft Visual
Studio 14.0\
On Tuesday, 5 July 2016 at 19:25:50 UTC, WebFreak001 wrote:
On Tuesday, 5 July 2016 at 19:14:32 UTC, Andrew Edwards wrote:
There is on --config=client for the current version of dub so
I went to the location of the source for
experimental_allocator and ran dub build --build=release
On 07/05/2016 11:43 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
On Tuesday, July 05, 2016 11:16:31 Charles Hixson via Digitalmars-d-learn
wrote:
What I'm looking for is the opposite of the "FromUnixTime" function.
SysTime has toUnixTime, which is right above fromUnixTime in the
On Tuesday, 5 July 2016 at 19:43:02 UTC, WebFreak001 wrote:
On Tuesday, 5 July 2016 at 19:34:48 UTC, Andrew Edwards wrote:
It's more than that. Now, it fails because it can't find DMD.
As you can see in the build.bat from DCD it is hardcoded to
DMD:
I guess I was expressing myself poorly, probably due to muddled thinking
about the representation of time.
Based on various hints from you and others my current guess is that I
should use:
longnow() { returnClock.currTime().stdTime;}
IIUC this should return the current system
On Tuesday, July 05, 2016 12:51:54 Charles Hixson via Digitalmars-d-learn
wrote:
> On 07/05/2016 11:43 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
> > On Tuesday, July 05, 2016 11:16:31 Charles Hixson via Digitalmars-d-learn
> >
> > wrote:
> >> What I'm looking for is the opposite of the
How can I create (and update) and associative array where the key
is a string, and the value is a dynamic array of integers?
For example:
void insertValue( int[][string]aa, string key, int value )
{
int[]* keyvalue;
keyvalue = ( key in aa );
if ( keyvalue !is null )
{
On Tuesday, July 05, 2016 16:18:19 Charles Hixson via Digitalmars-d-learn
wrote:
> I guess I was expressing myself poorly, probably due to muddled thinking
> about the representation of time.
>
> Based on various hints from you and others my current guess is that I
> should use:
>
> longnow()
Thank you for confirming the change. It hasn't made any difference
during the tests so far, but it sounds like it soon would have.
I don't really want a long...but an int rolls over too quickly, and
there's no 48 bit time. The time is basically for use over smaller
intervals, but
On Wednesday, 6 July 2016 at 02:03:54 UTC, Adam D. Ruppe wrote:
On Wednesday, 6 July 2016 at 01:58:31 UTC, Craig Dillabaugh
wrote:
*(keyvalue) ~ value; // This line fails.
That should prolly be ~= instead of ~.
Ahh, I was so close. Thank you that seems to do the trick.
However,
On Wednesday, 6 July 2016 at 01:58:31 UTC, Craig Dillabaugh wrote:
*(keyvalue) ~ value; // This line fails.
That should prolly be ~= instead of ~.
On Wednesday, 6 July 2016 at 02:19:47 UTC, Craig Dillabaugh wrote:
Why doesn't my function allow me to insert elements into an
empty associative array, but succeeds for an AA with some
element in it?
this is true for any dynamic array, including AAs. until
something is added to array, it
On Tuesday, 5 July 2016 at 22:03:43 UTC, ketmar wrote:
On Tuesday, 5 July 2016 at 21:58:39 UTC, Ola Fosheim Grøstad
wrote:
On Tuesday, 5 July 2016 at 21:46:19 UTC, ketmar wrote:
C++ templates vs D templates. this alone is enough.
They are almost the same...
yep. just like C is *almost* the
On 7/5/16 3:51 PM, Charles Hixson via Digitalmars-d-learn wrote:
On 07/05/2016 11:43 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
On Tuesday, July 05, 2016 11:16:31 Charles Hixson via Digitalmars-d-learn
wrote:
What I'm looking for is the opposite of the "FromUnixTime" function.
On Tuesday, 5 July 2016 at 21:46:19 UTC, ketmar wrote:
C++ templates vs D templates. this alone is enough.
They are almost the same...
On Wednesday, 6 July 2016 at 02:33:02 UTC, ketmar wrote:
On Wednesday, 6 July 2016 at 02:19:47 UTC, Craig Dillabaugh
wrote:
[...]
this is true for any dynamic array, including AAs. until
something is added to array, it actually a `null` pointer. i.e.
arrays (and AAs) generally consisting of
auto concat(T : E[n], E, size_t n)(const E[][] args...) @nogc
{
size_t offset = 0;
T result = void;
foreach(arr; args) {
result[offset .. offset+arr.length] = arr;
offset += arr.length;
}
assert(offset == result.length);
return result;
}
static immutable
Am 05.07.2016 um 17:12 schrieb Johannes Loher:
> Am 05.07.2016 um 16:39 schrieb Rene Zwanenburg:
>> On Tuesday, 5 July 2016 at 12:34:20 UTC, Johannes Loher wrote:
>>> I tried this, but it does not work correctly with slices.
>>
>> The length of a slice is a runtime value, which is why it can't be
Am 05.07.2016 um 17:22 schrieb Marc Schütz:
> auto concat(T : E[n], E, size_t n)(const E[][] args...) @nogc
> {
> size_t offset = 0;
> T result = void;
> foreach(arr; args) {
> result[offset .. offset+arr.length] = arr;
> offset += arr.length;
> }
>
Am 05.07.2016 um 16:39 schrieb Rene Zwanenburg:
> On Tuesday, 5 July 2016 at 12:34:20 UTC, Johannes Loher wrote:
>> I tried this, but it does not work correctly with slices.
>
> The length of a slice is a runtime value, which is why it can't be used
> to set static array size. What were you
On Tuesday, 5 July 2016 at 13:48:46 UTC, Claude wrote:
Ah ok. I tried using void[size] static array and it seems to
work without having to use GC.addRange().
Correct. void[] means the type of the data is unknown, so the GC
has to assume it can contain pointers.
This also means that
On 07/05/2016 07:25 AM, ketmar wrote:
cast `shared` away. yes, this is how you supposed to use it now: cast it
away.
after having ensured thread safety that is
On Tuesday, 5 July 2016 at 16:20:52 UTC, ketmar wrote:
so, my PoV is: yes, D has it's warts, but they are much more
tolerable than C++ warts, for example. and D has alot to offer
which C++ simply won't be able to offer, ever.
D has «static if», but what else are you thinking of? The only
On Tue, Jul 05, 2016 at 04:11:58PM +, zabruk70 via Digitalmars-d-learn
wrote:
> On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
> > Property functions are used wrong by a compiler when it needs
>
> i am sorry for my dumbness, what wrong with this code?
>
> import std.stdio;
>
> struct
On Tuesday, 5 July 2016 at 16:11:58 UTC, zabruk70 wrote:
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
Property functions are used wrong by a compiler when it needs
i am sorry for my dumbness, what wrong with this code?
as OP said, this one won't call setter on "+=" and company.
On Tuesday, 5 July 2016 at 14:07:25 UTC, zodd wrote:
http://forum.dlang.org/post/mailman.1463.1361561853.22503.digitalmars-d-le...@puremagic.com
: "Don't use 'in', because it doesn't mean what it seems to mean, and it's not
correctly implemented at the moment."
it is freakin' 2013! ;-)
On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
Property functions are used wrong by a compiler when it needs
i am sorry for my dumbness, what wrong with this code?
import std.stdio;
struct A {
@property ref int value() {
return value_;
}
@property void value(int v)
I've been reading std.datetime documentation backwards and forwards, but
if the information is there, I've been missing it.
How do I get the current time as a long?
Clock.currTime() returns a SysTime, and while currently I can convert
that to a long, this is because I looked into the code.
On Tuesday, 5 July 2016 at 17:50:46 UTC, Ola Fosheim Grøstad
wrote:
On Tuesday, 5 July 2016 at 16:20:52 UTC, ketmar wrote:
so, my PoV is: yes, D has it's warts, but they are much more
tolerable than C++ warts, for example. and D has alot to offer
which C++ simply won't be able to offer, ever.
On Tuesday, 5 July 2016 at 21:58:39 UTC, Ola Fosheim Grøstad
wrote:
On Tuesday, 5 July 2016 at 21:46:19 UTC, ketmar wrote:
C++ templates vs D templates. this alone is enough.
They are almost the same...
yep. just like C is *almost* the assembler.
66 matches
Mail list logo