I don't know much more about D than creating a 'hello world' exe
file with the DMD Compiler
but I'm interested in using the eBay/tsv-utils binaries.
Unfortunately, the author didn't create any MS Windows binaries:
https://github.com/eBay/tsv-utils/releases
Does anyone know how to compile this co
Can I make it work?
struct S
{
int[] l;
}
then
auto s = S();
s.l ~= 1; // ok
s.l = []; // error
assume the files:
app.d
void main() {
import myModule : foo;
writeln(foo(...));
}
myModule.d
module myModule;
int foo(int n) { }
the following fail:
dmd -run app.d mymodule.d
give error like this:
Error: module `myModule` is in file 'myModule.d' which cannot
be read
but
On Tuesday, 13 March 2018 at 19:05:00 UTC, Jonathan M Davis wrote:
On Tuesday, March 13, 2018 18:55:35 Marc via
Digitalmars-d-learn wrote:
I want to basically make this work:
>[...]
I managed to do this:
> [...]
}
Note the ref in the fucntion return, I also want to return a
reference
I want to basically make this work:
auto l = new List();
l += 5;
I managed to do this:
class List
{
int[] items;
ref List opBinary(string op)(int rhs) if(op == "+")
{
items ~= rhs;
return *this;
}
}
Note the ref in the fucntio
On Thursday, 8 March 2018 at 17:06:05 UTC, Marc wrote:
How do I define the callback so that it can be used in
RegisterWaitForSingleObject()?
I've tried pass as argument:
myFunc
&myFunc
myFunc.ptr
none worked. Here's my code:
[...]
Function call:
[...]
Error:
[...]
Solved! I shall
How do I define the callback so that it can be used in
RegisterWaitForSingleObject()?
I've tried pass as argument:
myFunc
&myFunc
myFunc.ptr
none worked. Here's my code:
extern (C) void OnExited(void* context, BOOLEAN isTimeOut);
extern(Windows):
BOOL RegisterWaitForSingleObject(
On Wednesday, 7 March 2018 at 16:12:28 UTC, Matt Gamble wrote:
On Wednesday, 7 March 2018 at 16:10:15 UTC, Marc wrote:
On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
[...]
works for me as expected.
ln(largest double) =
On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
I don't understand why I'm getting an 'inf' by raising E to a
real number, e^^710.0L. See below.
import std.stdio;
import std.math;
unittest
{
writefln("ln(largest double) =
On Wednesday, 7 March 2018 at 16:06:26 UTC, Matt Gamble wrote:
On Wednesday, 7 March 2018 at 16:00:39 UTC, Alex wrote:
On Wednesday, 7 March 2018 at 15:44:28 UTC, Matt Gamble wrote:
[...]
works for me as expected.
ln(largest double) = 709.783
e^710 = inf
ln(largest real) = 11356.5
e^710 = 2.
I do need to start (up to 4 a time) processes in parallel but I'd
like to get notified (similar to C#'s Process.Exited Event) when
the process exits. How can I do that in D?
I'm trying to use this resource to set executable's
information/metadata but it fail to set anything but the icon,
without any error message. Could anyone point out if there's
anything wrong with my approach?
(if anyone use a different approach/toolset to set those data,
your suggestion is very
I added the followiing to my dub.json:
"preBuildCommand": [
"C:\\Users\\user003\\Desktop\\Nova pasta\\a.exe",
"C:\\dm\\bin\\rcc.exe -32 -D__NT__ res.rc -o sources\\res.res"
]
But neither command is executed.
"C:\\Users\\user003\\Desktop\\Nova pa
if so, can I somehow make it copy only if newest?
On Monday, 5 March 2018 at 18:57:01 UTC, Steven Schveighoffer
wrote:
On 3/5/18 1:35 PM, Robert M. Münch wrote:
If I use VisualD and add a watch on myObj, I don't see
anything just a "identifier myObj is undefined". Not sure if
this is because of some threads running (using the D RX
framework)
On Monday, 5 March 2018 at 05:35:28 UTC, J-S Caux wrote:
I'm considering shifting a large existing C++ codebase into D
(it's a scientific code making much use of functions like atan,
log etc).
I've compared the raw speed of atan between C++ (Apple LLVM
version 7.3.0 (clang-703.0.29)) and D (d
Does anyone knows about any crash repórter library for D? there's
nothing I couldn't find at code packages. Something as simple and
easy to use like this C#'s
https://archive.codeplex.com/?p=crashreporterdotnet
then copy it to sources folder?
let's say I have a small library folder at C:\mylibrary\D where I
want to use dir.d from it. How do I add that file dependence to
dub? But I do not want to that file be passed directly to dmd, I
want to that file be copied to application's source folder (so
it'
On Tuesday, 27 February 2018 at 16:55:27 UTC, Marc wrote:
[...]
So deep down the error is in that method which I call from
deserializeLine() function:
void setValue(T, V)(auto ref T aggregate, string field, V
value) {
writeln("setting {", field, "} to {", value,
On Tuesday, 27 February 2018 at 15:08:23 UTC, Stefan Koch wrote:
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:
I've tried both gdb and windbg debugger both it either get a
"received signal ?" from gdb or crash the GUI application
(windbg).
The error is:
core.exception.OutOfMemoryEr
On Tuesday, 27 February 2018 at 15:08:23 UTC, Stefan Koch wrote:
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:
I've tried both gdb and windbg debugger both it either get a
"received signal ?" from gdb or crash the GUI application
(windbg).
The error is:
core.exception.OutOfMemoryEr
On Tuesday, 27 February 2018 at 14:06:19 UTC, Nicholas Wilson
wrote:
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:
I've tried both gdb and windbg debugger both it either get a
"received signal ?" from gdb or crash the GUI application
(windbg).
The error is:
core.exception.OutOfMemo
On Monday, 26 February 2018 at 18:01:07 UTC, Marc wrote:
I've tried both gdb and windbg debugger both it either get a
"received signal ?" from gdb or crash the GUI application
(windbg).
The error is:
core.exception.OutOfMemoryError@src\core\exception.d(696):
Memory allocation failed
How do
I've tried both gdb and windbg debugger both it either get a
"received signal ?" from gdb or crash the GUI application
(windbg).
The error is:
core.exception.OutOfMemoryError@src\core\exception.d(696):
Memory allocation failed
How do I find out the source of the error?
I'm pretty sure something could be done with Ada's type range but
what we could do using D?
On Monday, 12 February 2018 at 17:29:47 UTC, Jonathan M Davis
wrote:
On Monday, February 12, 2018 17:07:50 Marc via
Digitalmars-d-learn wrote:
[...]
If you actually use the enum values anywhere other than with
anything from std.conv, std.format, or std.stdio, then when
they get converted to
appender doesn't support string[] so in such case:
string[] output;
for(...) {
if(...) {
output ~= str;
}
}
Looking for avoid as many immediate allocations as possible, what
should I use?
If I have an enum like this:
enum S : string {
foo = "a",
baa = "b"
}
when I printed it, to my surprise I get the enum field name
rather value:
writefln("%s v%s", S.foo, S.baa);
output:
foo vbaa
instead of
a vb
a cast solves it but without cast everywhere I
On Monday, 12 February 2018 at 15:51:58 UTC, Marc wrote:
the warning is:
Non-selected package lnk is available with version ~>0.2.1.
What does it mean by *Non-selected* package lnk is available?
from what I could tell from the page, it's highest version.
But I've tried low versions anyway to
the warning is:
Non-selected package lnk is available with version ~>0.2.1.
What does it mean by *Non-selected* package lnk is available?
from what I could tell from the page, it's highest version.
But I've tried low versions anyway to see if it Works 0.2.0,
0.1.1 etc and none did.
I notici
I do call a program from my application which changes its stdout
perdiodically (with ncurses library, I guess), where I'd to get
somehow "notified" when some change happen (I need to new data
from that changes and change my application accordingly).
Currently, I do use spawnProcess() which runs
On Monday, 5 February 2018 at 18:40:40 UTC, Steven Schveighoffer
wrote:
On 2/5/18 1:27 PM, Vino wrote:
Hi All,
Request your help on how to convert a string to binary,eg
"test" to 01110100 01100101 01110011 01110100.
import std.stdio, std.string;
writefln("%(%b %)", "test".representation);
-
On Thursday, 8 February 2018 at 07:21:05 UTC, Jonathan M Davis
wrote:
On Wednesday, February 07, 2018 13:39:55 Timothee Cour via
Digitalmars-d- learn wrote:
[...]
It's useful with stuff like version(Ddoc).
[...]
What's a di file? (sorry google didn't help with that)
It's been my understa
I was using a Sqlite3 library then I included another library
that started the conflict. From what I could tell, it seems it's
another Sqlite3 engine that the included library uses. The link
error is:
.dub\build\application-debug-windows-x86-dmd_2076-E7D07B7BDA58325E30A3C637FC043AFE\foo.obj(y
I was looking for a library to use SQLite with D, found this
(https://code.dlang.org/packages/sqlite-d) but it has no
documentation or code example. I looked into files in the source
code and wrote this:
Database db = Database(name);
auto table = db.table(tableName);
auto rows = table.findRow
I'm used to use Qt's QWebView when I need an application to show
a HTML page and change some elements on it. This time, if
possible, I'd like to use D instead. Are there any web browsers
ports in D?
in C# you can initilizate the class members like this:
var foo = new Foo { a = 1, b = 2 };
I found something similar to structs in D:
myStruct S = {a:1, b:2};
But can't figure out if D does have that for classes.
On Monday, 15 January 2018 at 07:37:42 UTC, Simen Kjærås wrote:
On Sunday, 14 January 2018 at 22:07:22 UTC, Marc wrote:
thanks, can i use it at compile time as well?
enum isMutableString(string field) =
is(typeof(__traits(getMember, >C, field)) == string);
static foreach(field; [Fiel
let's assume I have
class C {
static string foo() { writeln("got called!"); // }
}
then I want to cache foo at some point:
import std.algorithm;
auto v = cache(c.foo);
I call do:
for(int i = 0; i <10; i++) {
writeln(v);
}
then it'll print "got called" only once, which is what I
On Sunday, 14 January 2018 at 21:59:26 UTC, Seb wrote:
On Sunday, 14 January 2018 at 21:21:52 UTC, Marc wrote:
give a list, how can I select only the elements of a range
according to a condition give by a lamba function?
something like this:
auto l = myList.select(e => e.id < 300);
it woul
On Sunday, 14 January 2018 at 21:38:39 UTC, drug wrote:
15.01.2018 00:21, Marc пишет:
give a list, how can I select only the elements of a range
according to a condition give by a lamba function?
something like this:
auto l = myList.select(e => e.id < 300);
it would return a range. Similar
give a list, how can I select only the elements of a range
according to a condition give by a lamba function?
something like this:
auto l = myList.select(e => e.id < 300);
it would return a range. Similar to C#'s select:
https://msdn.microsoft.com/en-us/library/bb548891(v=vs.110).aspx
On Sunday, 14 January 2018 at 19:08:44 UTC, Marc wrote:
On Sunday, 14 January 2018 at 18:18:50 UTC, Marc wrote:
I didn't find how using traits I could get a class member
type? I need to test if give class member is not immutable, I
find isMutable but not how get a type from give class member
t
On Sunday, 14 January 2018 at 18:18:50 UTC, Marc wrote:
I didn't find how using traits I could get a class member type?
I need to test if give class member is not immutable, I find
isMutable but not how get a type from give class member to pass
to it.
for clarify, I want all this at compile t
I didn't find how using traits I could get a class member type? I
need to test if give class member is not immutable, I find
isMutable but not how get a type from give class member to pass
to it.
On Friday, 12 January 2018 at 22:03:53 UTC, H. S. Teoh wrote:
On Fri, Jan 12, 2018 at 10:03:40PM +, Marc via
Digitalmars-d-learn wrote:
How do I use?
> static foreach(enum string member; members) {
>static if(isFunction!(__traits(getMember, C,
How do I use?
static foreach(enum string member; members) {
static if(isFunction!(__traits(getMember, C, m ember)))
{
continue;
}
give error:
must use labeled continue within static foreach
then I tried:
out
On Friday, 12 January 2018 at 05:14:12 UTC, Jonathan M Davis
wrote:
On Thursday, January 11, 2018 14:07:18 Ali Çehreli via
Digitalmars-d-learn wrote:
[...]
And if all what you're doing is printing the value out, you
might as well just print the Duration directly rather than
calling total. Du
I stuck at this and can't figure out the reason why the value of
the variable ds is 0 when I do this: startTime =
MonoTime.currTime; if I remove that statement, the value of ds
isn't zeroed, it has the actual number of seconds. But I can't
figure out, ds is of integer type and such, it is copie
void foo() {
void baa() {
static int n;
writeln(n++);
}
}
void main() {
static int x;
foo();
doSomething(x);
}
does x and n has same lifetime, i.e, program's execution or n is
longer available onde foo() call reach out of scope?
On Thursday, 4 January 2018 at 00:02:24 UTC, Ali Çehreli wrote:
On 01/03/2018 03:48 PM, Marc wrote:
I found no way with __traits() on std.traits. I found
isStaticFunction and isStaticArray but nothing about a member.
Is this by desgin?
Give a class like:
class C { static int a, b, c; int d;
For code generation purposes, I'd like to pass a type name to
base class. I'm not sure if it's supported, I didn't find
anything at documentation for class constructor but it does
compile:
class A {
static {
int a, b;
}
this(T)() {
}
}
then
On Thursday, 4 January 2018 at 19:16:03 UTC, Marc wrote:
For code generation purposes, I'd like to pass a type name to
base class. I'm not sure if it's supported, I didn't find
anything at documentation for class constructor but it does
compile:
class A {
static {
int
I found no way with __traits() on std.traits. I found
isStaticFunction and isStaticArray but nothing about a member. Is
this by desgin?
Give a class like:
class C { static int a, b, c; int d; }
I'd like to get a, b and c.
I'm using this:
__traits(allMembers, C)
On Wednesday, 3 January 2018 at 18:59:39 UTC, Ali Çehreli wrote:
On 01/03/2018 10:50 AM, Marc wrote:
when calling winapi functions, usually you to deal with the
result in wchar[]. How do I convert it to string in D to be
usable by the application? does D have a native for this?
std.conv has t
when calling winapi functions, usually you to deal with the
result in wchar[]. How do I convert it to string in D to be
usable by the application? does D have a native for this?
for a safe programming, since C/C++ times I try to make thing
const as possible. locals, parameters etc anything which isn't
going to change.
How do you do that in D? immutable everywhere?
for example:
foreach(Field field; fields) {
immutable string htmlOutputfile = ge
Long time ago, IIRC, I read somewhere there was a ncurses for D
but now I can't find it are there any wrapper or am I mistaken?
anyway, I'm doing it from scratch and not porting anything so
even a library with same functionality as ncurses for D is
welcome.
I got compilers errors from this:
enum E {
@("foo")
A,
@("baa")
B
}
I got:
Error: basic type expected, not @
Error: no identifier for declarator _error_
Error: type only allowed if anonymous enum and no enum type
Error: if type, there must be an initializer
Er
On Saturday, 30 December 2017 at 23:30:02 UTC, rjframe wrote:
On Sat, 30 Dec 2017 13:07:49 +, Marc wrote:
how do I take a symbol as parameter?
for example:
template nameof(alias S) {
import std.array : split;
enum nameof = S.stringof.split(".")[$-1];
}
Works fine for sa
On Sunday, 31 December 2017 at 22:50:12 UTC, Marc wrote:
On Saturday, 30 December 2017 at 23:30:02 UTC, rjframe wrote:
On Sat, 30 Dec 2017 13:07:49 +, Marc wrote:
how do I take a symbol as parameter?
for example:
[...]
Works fine for say a enum member such nameof!(myEnum.X) but
this:
On Saturday, 30 December 2017 at 23:30:02 UTC, rjframe wrote:
On Sat, 30 Dec 2017 13:07:49 +, Marc wrote:
how do I take a symbol as parameter?
for example:
template nameof(alias S) {
import std.array : split;
enum nameof = S.stringof.split(".")[$-1];
}
Works fine for sa
how do I take a symbol as parameter?
for example:
template nameof(alias S) {
import std.array : split;
enum nameof = S.stringof.split(".")[$-1];
}
Works fine for say a enum member such nameof!(myEnum.X) but this:
struct S { int v; }
S s;
writefln(name
Always helpful. Thank you very much guys.
I'd like to set the members of a class by its name at runtime, I
would do something like this:
__traits(getMember, myClass, name) = value;
but since name is only know at runtime, I can't use __traits().
What's a workaround for this?
I do build a string by coping large parts of diffrent buffers,
all those buffers live after the functional call, so rather than
duplicate those string I'd like to copy only references to those
parts rather duplicate every string. I combined appender!string,
assumeUnique() and array slices. Some
of course a totally different approach to solve this is welcome,
I came from C/C++/C# worlds so I'm in the process of slowly
converting my thinking to the D way (which is new for me, since
I'm even unifamiliar with python and such, which got such
friendly syntax)
something like this:
struct S {
// variables...
string doGen(int n) { return ""; }
alias gen = memoize!doGen;
}
The error I got is:
Error: need 'this' for 'doGen' of type 'string(int n)'
I can't make doGen static because it access non-static struct
members... can I workaround this?
Does to!(string)(char[]) do any memory allocation on conversion
or is this similar to a cast or what else?
for example:
scope struct S {
int x;
}
What does scope do here?
How can I create a alias to a struct method?
struct S {
string doSomething(int n) { return ""; }
}
I'd like to do something like this (imaginary code):
alias doSomething = S.doSomething;
then call it by doSomething(3)
I got the following error from this code:
Error: need 'this' for 'gen'
For example, I'd like to declare a variable inside a static
foreach like in below code, just for better organization,
otherwise, I have to use the value directly instead of the
variable. If the value is used more than once, it might be
inviable.
enum allMembers = __traits(derivedMemb
On Wednesday, 20 December 2017 at 17:16:50 UTC, Mengu wrote:
On Wednesday, 20 December 2017 at 16:54:35 UTC, Marc wrote:
Give this function I'd like to run it at compile time:
import std.concurrency : Generator, yield;
[...]
but when I do:
[...]
I get the following erros:
C:\D\d
Give this function I'd like to run it at compile time:
import std.concurrency : Generator, yield;
Generator!string getNonIntegralMembers() {
return new Generator!string({
enum allMembers = __traits(derivedMembers, C);
On Tuesday, 19 December 2017 at 15:52:57 UTC, Dgame wrote:
On Tuesday, 19 December 2017 at 15:19:53 UTC, Marc wrote:
[...]
template FirstOf(T...) {
template otherwise(D) {
static if (T.length == 0) {
enum otherwise = D.init;
} else {
enum otherwise =
On Tuesday, 19 December 2017 at 00:01:00 UTC, Ali Çehreli wrote:
On 12/18/2017 03:54 PM, Ali Çehreli wrote:
On 12/18/2017 02:58 PM, Marc wrote:
Here's another experiment:
template FirstOf(T...) {
template otherwise(D) {
static if (T.length == 0) {
enum otherwise = D.in
Imaginary code:
int index = FirstOrDefault!(int)(__traits(getAttributes, C.a));
In that case, if the tuple is empty, the value is the int's type
default value.
The method is defined as following:
template FirstOrDefault(X)(T...) {
static if(T.length > 0) {
enum Fi
On Saturday, 16 December 2017 at 20:05:15 UTC, Anonymouse wrote:
On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote:
C# has a quite nice way to store metadata about a property by
a feature called atributes[1]. For example, I can write
something like this:
class A {
[TextSize(256)]
C# has a quite nice way to store metadata about a property by a
feature called atributes[1]. For example, I can write something
like this:
class A {
[TextSize(256)]
string Name { get; set; }
}
So using runtime/reflection I can retrieve the TextSize value
associated to A.name property.
On Saturday, 16 December 2017 at 03:48:01 UTC, Jonathan M Davis
wrote:
On Saturday, December 16, 2017 03:34:43 Marc via
Digitalmars-d-learn wrote:
I need to give a class C, read all user-defined members of it,
both name and value dynamically. for example:
> [...]
then
>[...]
I ge
On Saturday, 16 December 2017 at 07:23:38 UTC, Jonathan M Davis
wrote:
On Saturday, December 16, 2017 04:01:10 Marc via
Digitalmars-d-learn wrote:
how do I from class:
> class Person {
>
> string name;
> int age;
>
> }
do:
> auto c = [__traits(allMembers, Person)];
th
how do I from class:
class Person {
string name;
int age;
}
do:
auto c = [__traits(allMembers, Person)];
then return only ["name", "age"] rather ["name, "age", "ctor",
"toString" ... ]?
I need to give a class C, read all user-defined members of it,
both name and value dynamically. for example:
class C {
string a;
string b;
string c;
}
then
Class c = new C();
// set c members...
enum string[] members = [__traits(allMembers, C)];
foreach(string member; members) {
Kozak
wrote:
Something like this:
https://dlang.org/phobos/std_uni.html#asCapitalized
On Tue, Dec 5, 2017 at 2:31 PM, Marc via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
Does D have a native function to capitalize only the first
letter of the word? (I'm askin
Does D have a native function to capitalize only the first letter
of the word? (I'm asking that so I might avoid reinvent the
wheel, which I did sometimes in D)
On Thursday, 23 November 2017 at 01:34:54 UTC, Ali Çehreli wrote:
On 11/22/2017 05:21 PM, Marc wrote:
On Thursday, 23 November 2017 at 01:04:29 UTC, Jonathan M
Davis wrote:
On Thursday, November 23, 2017 00:58:21 Marc via
Digitalmars-d-learn wrote:
[...]
import std.traits;
enum countOfA
On Thursday, 23 November 2017 at 01:04:29 UTC, Jonathan M Davis
wrote:
On Thursday, November 23, 2017 00:58:21 Marc via
Digitalmars-d-learn wrote:
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
import std.traits;
enum
On Thursday, 23 November 2017 at 01:01:42 UTC, Michael V.
Franklin wrote:
On Thursday, 23 November 2017 at 00:58:21 UTC, Marc wrote:
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
https://dlang.org/spec/traits.html#allMembe
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
89 matches
Mail list logo