Re: D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 19:19:19 UTC, Andre Pany wrote: On Tuesday, 5 September 2017 at 18:37:17 UTC, EntangledQuanta wrote: On Tuesday, 5 September 2017 at 08:13:02 UTC, Andre Pany wrote: On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta wrote: I would like to use D as a

Re: run unittest inside program

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 06, 2017 02:06:59 Psychological Cleanup via Digitalmars-d-learn wrote: > Is it possible to run a unit test without adding -unittest to the > command line? > > unittest X > { > pragma(msg, "Boo!"); > } > > X; > > void main() { } No. Without -unittest, the unittest

Re: Can attributes trigger functionality?

2017-09-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 02:43:20 UTC, Psychological Cleanup wrote: I'm having to create a lot of boiler plate code that creates "events" and corresponding properties(getter and setter). I'm curious if I can simplify this without a string mixin. You certainly don't need a string

Re: Using closure causes GC allocation

2017-09-05 Thread Vino.B via Digitalmars-d-learn
On Monday, 4 September 2017 at 14:42:45 UTC, Azi Hassan wrote: On Monday, 4 September 2017 at 05:45:18 UTC, Vino.B wrote: In order to resolve the issue "Using closure causes GC allocation" it was stated that we need to use delegates Alternatively you can drop the functional style and use a

Re: Can attributes trigger functionality?

2017-09-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 02:43:20 UTC, Psychological Cleanup wrote: I'm having to create a lot of boiler plate code that creates "events" and corresponding properties(getter and setter). I'm curious if I can simplify this without a string mixin. If I create my own attribute like

Re: D scripting

2017-09-05 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 19:44:40 UTC, EntangledQuanta wrote: Just an idea for you: in delphi you can set the properties of a component (a class with runtime reflection enabled) on runtime. You can even call the methods and events of a component. I build a Delphi Bridge for D (see

Re: Finding chars in strings

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 05, 2017 18:04:16 ag0aep6g via Digitalmars-d-learn wrote: > On 09/05/2017 05:54 PM, Per Nordlöw wrote: > > Follow up question: If a character literal has type char, can we always > > assume it's an ASCII character? > > Strictly speaking, this is a character literal of type

Re: Making a repo of downloaded dub package

2017-09-05 Thread Dukc via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 08:43:02 UTC, Jonathan M Davis wrote: Yeah. I'm fairly certain that that's your only option. dub is not designed with the idea that you would be editing the source code that it downloads. That's just intended for building the code that you are editing. It does

Re: Finding chars in strings

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 05, 2017 17:55:20 ag0aep6g via Digitalmars-d-learn wrote: > On 09/05/2017 05:43 PM, Per Nordlöw wrote: > > If a character literal has type char, always below 128, can we always > > search for it's first byte offset in a string without decoding the > > string to a range of

Re: D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 19:59:27 UTC, Andre Pany wrote: On Tuesday, 5 September 2017 at 19:44:40 UTC, EntangledQuanta wrote: Just an idea for you: in delphi you can set the properties of a component (a class with runtime reflection enabled) on runtime. You can even call the methods and

Re: Making a repo of downloaded dub package

2017-09-05 Thread Dukc via Digitalmars-d-learn
On Monday, 4 September 2017 at 20:31:35 UTC, Igor wrote: Search for word "local" here: https://code.dlang.org/docs/commandline. Maybe some of those can help you. If not you could make a pull request for dub that would support such a thing :) That will make a Dub package out of a Git package,

Re: DUB and LTO?

2017-09-05 Thread Jon Degenhardt via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 11:36:06 UTC, Sönke Ludwig wrote: Am 24.01.2017 um 17:02 schrieb Las: How do I enable LTO in DUB in a sane way? I could add it to dflags, but I only want it on release builds. You can put a "buildTypes" section in your package recipe and override default

run unittest inside program

2017-09-05 Thread Psychological Cleanup via Digitalmars-d-learn
Is it possible to run a unit test without adding -unittest to the command line? unittest X { pragma(msg, "Boo!"); } X; void main() { }

Can attributes trigger functionality?

2017-09-05 Thread Psychological Cleanup via Digitalmars-d-learn
I'm having to create a lot of boiler plate code that creates "events" and corresponding properties(getter and setter). I'm curious if I can simplify this without a string mixin. If I create my own attribute like @Event double foo(); and I write any code that will trigger when the event is

Re: Making a repo of downloaded dub package

2017-09-05 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 06:23:26 UTC, Dukc wrote: On Monday, 4 September 2017 at 20:31:35 UTC, Igor wrote: Search for word "local" here: https://code.dlang.org/docs/commandline. Maybe some of those can help you. If not you could make a pull request for dub that would support such a

Re: D scripting

2017-09-05 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta wrote: I would like to use D as a "scripting" language for my D app. There seems to be no such thing. Since we can include the D compiler in our distribution, it is easy to enable "plugin" capabilities, but directly interfacing

Re: Making a repo of downloaded dub package

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 05, 2017 07:52:03 Rene Zwanenburg via Digitalmars-d- learn wrote: > On Tuesday, 5 September 2017 at 06:23:26 UTC, Dukc wrote: > > On Monday, 4 September 2017 at 20:31:35 UTC, Igor wrote: > >> Search for word "local" here: > >> https://code.dlang.org/docs/commandline. Maybe

Re: fromStringz for wide characters

2017-09-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 05, 2017 08:15:04 John Burton via Digitalmars-d-learn wrote: > std.string.fromStringz will create me a string from a null > terminated array of characters. But I have a zero terminated > array of "short"s (from a win32 api call) which I'd like to turn > into a wstring. But

D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn
I would like to use D as a "scripting" language for my D app. There seems to be no such thing. Since we can include the D compiler in our distribution, it is easy to enable "plugin" capabilities, but directly interfacing with the source code seems like it would require a bit of

Re: replace switch for mapping

2017-09-05 Thread Andrea Fontana via Digitalmars-d-learn
On Monday, 4 September 2017 at 20:54:27 UTC, EntangledQuanta wrote: On Monday, 4 September 2017 at 09:23:24 UTC, Andrea Fontana wrote: On Thursday, 31 August 2017 at 23:17:52 UTC, EntangledQuanta wrote: Generally one has to use a switch to map dynamic components. Given a set X and Y one can

fromStringz for wide characters

2017-09-05 Thread John Burton via Digitalmars-d-learn
std.string.fromStringz will create me a string from a null terminated array of characters. But I have a zero terminated array of "short"s (from a win32 api call) which I'd like to turn into a wstring. But there doesn't seem to be a function to do this. Do I need to write my own, or am I

Re: Struct with float members in betterC

2017-09-05 Thread user1234 via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 11:58:18 UTC, Azi Hassan wrote: Hi, I'm trying to create the following struct in betterC but I keep getting undefined reference errors when I try to compile the code : [...] I'm aware that betterC is still experimental at this point, but I thought I'd ask

Finding chars in strings

2017-09-05 Thread Per Nordlöw via Digitalmars-d-learn
If a character literal has type char, always below 128, can we always search for it's first byte offset in a string without decoding the string to a range of dchars?

DLang IDE [RU]

2017-09-05 Thread TM via Digitalmars-d-learn
Да простят англоязычные участники :) С попеременным успехом пытаюсь оседлать DLang IDE, связи с чем накопился ряд вопросов, прежде всего к автору. Рабочая станция: I3-550, ОС Windows 7 Pro SP1 русская, 32 битная. 1. Невозможно собрать как IDE, так и любой пример из DlangUI, если в профиле

Re: Finding chars in strings

2017-09-05 Thread ag0aep6g via Digitalmars-d-learn
On 09/05/2017 05:43 PM, Per Nordlöw wrote: If a character literal has type char, always below 128, can we always search for it's first byte offset in a string without decoding the string to a range of dchars? Yes. You can search for ASCII characters (< 128) without decoding. The values in

Re: Finding chars in strings

2017-09-05 Thread ag0aep6g via Digitalmars-d-learn
On 09/05/2017 05:54 PM, Per Nordlöw wrote: Follow up question: If a character literal has type char, can we always assume it's an ASCII character? Strictly speaking, this is a character literal of type char: '\xC3'. It's clearly above 0x7F, and not an ASCII character. So, no. But if it's an

Re: Finding chars in strings

2017-09-05 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 15:43:02 UTC, Per Nordlöw wrote: If a character literal has type char, always below 128, can we always search for it's first byte offset in a string without decoding the string to a range of dchars? Follow up question: If a character literal has type char, can

Re: SIMD under LDC

2017-09-05 Thread Igor via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 01:11:29 UTC, 12345swordy wrote: On Monday, 4 September 2017 at 23:06:27 UTC, Nicholas Wilson wrote: Don't underestimate ldc's optimiser ;) I seen cases where the compiler fail to optimized for smid. I tried it and LDC optimized build did generate SIMD

Re: DLang IDE [RU]

2017-09-05 Thread TM via Digitalmars-d-learn
Из более серьезных улучшений, я бы предложил возможность в Workspace Explorer добавлять пакеты, переименовывать пакеты / модули, перемещать пакеты / модули и удалять пакеты / модули. Но это, очевидно уже будет требовать некоторых усилий на реализацию. А так, за неимением, IDE работает впаре с

Re: D scripting

2017-09-05 Thread EntangledQuanta via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 08:13:02 UTC, Andre Pany wrote: On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta wrote: I would like to use D as a "scripting" language for my D app. There seems to be no such thing. Since we can include the D compiler in our distribution, it is

Re: SIMD under LDC

2017-09-05 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 4 September 2017 at 20:39:11 UTC, Igor wrote: I found that I can't use __simd function from core.simd under LDC and that it has ldc.simd but I couldn't find how to implement equivalent to this with it: ubyte16* masks = ...; foreach (ref c; pixels) { c = __simd(XMM.PSHUFB,

Re: D scripting

2017-09-05 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 18:37:17 UTC, EntangledQuanta wrote: On Tuesday, 5 September 2017 at 08:13:02 UTC, Andre Pany wrote: On Tuesday, 5 September 2017 at 07:32:24 UTC, EntangledQuanta wrote: I would like to use D as a "scripting" language for my D app. There seems to be no such

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote: Maybe it has something to do with how you read from STDIN. Can you show that part of the code to see if I can reproduce the issue ? I used `lines(stdin)` as in https://dlang.org/phobos/std_stdio.html#.lines . My source code

Re: vibed services stop response after several days of work

2017-09-05 Thread Sönke Ludwig via Digitalmars-d-learn
Am 01.09.2017 um 12:31 schrieb Suliman: On Friday, 1 September 2017 at 08:01:24 UTC, Suliman wrote: I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:40:18 UTC, Ky-Anh Huynh wrote: On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote: Maybe it has something to do with how you read from STDIN. Can you show that part of the code to see if I can reproduce the issue ? I used `lines(stdin)` as in

Re: DUB and LTO?

2017-09-05 Thread Sönke Ludwig via Digitalmars-d-learn
Am 24.01.2017 um 17:02 schrieb Las: How do I enable LTO in DUB in a sane way? I could add it to dflags, but I only want it on release builds. You can put a "buildTypes" section in your package recipe and override default dflags or lflags there just for the "release" build type. See

Struct with float members in betterC

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
Hi, I'm trying to create the following struct in betterC but I keep getting undefined reference errors when I try to compile the code : import core.stdc.stdio; struct Foo { float x; float y; float z; }; extern(C) int main(int argc, char** argv) { /*auto foo

Re: fromStringz for wide characters

2017-09-05 Thread John Burton via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 08:39:37 UTC, Jonathan M Davis wrote: On Tuesday, September 05, 2017 08:15:04 John Burton via Digitalmars-d-learn wrote: std.string.fromStringz will create me a string from a null terminated array of characters. But I have a zero terminated array of "short"s

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-09-05 Thread John Burton via Digitalmars-d-learn
On Thursday, 31 August 2017 at 21:06:17 UTC, Ivan Kazmenko wrote: On Thursday, 31 August 2017 at 14:43:39 UTC, Steven Schveighoffer wrote: Just a thought, but the "double printing" could be a misunderstanding. It could be printing Output\nOutput2, but not getting the 2 out there. Just to

Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, I read line from STDIN , and strip them [code] auto line_st = line.strip(); [/code] However, I can't use result in another format routine. Assume my input line is "foobar": [code] writeln("Stripped line is %s", line_st); [/code] This code only prints "Stripped line is ". If I use

Re: Simplest multithreading example

2017-09-05 Thread ag0aep6g via Digitalmars-d-learn
On 09/05/2017 03:15 AM, Brian wrote: Thanks very much for your help, I finally had time to try your suggestions. The initial example you showed does indeed have the same problem of not iterating over all values : double [] hugeCalc(int i){ // Code that takes a long time import

Performance Issue

2017-09-05 Thread Vino.B via Digitalmars-d-learn
Hi, The below code is consume more memory and slower can you provide your suggestion on how to over come these issues. string[][] csizeDirList (string FFs, int SizeDir) { ulong subdirTotal = 0; ulong subdirTotalGB; auto Subdata = appender!(string[][]); auto dFiles

Re: Performance Issue

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 09:44:09 UTC, Vino.B wrote: Hi, The below code is consume more memory and slower can you provide your suggestion on how to over come these issues. You can start by dropping the .array conversions after dirEntries. That way your algorithm will become lazy (as

Re: Performance Issue

2017-09-05 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 09:44:09 UTC, Vino.B wrote: Hi, The below code is consume more memory and slower can you provide your suggestion on how to over come these issues. [...] Much slower then ?

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 12:38:54 UTC, Ky-Anh Huynh wrote: Hi, I read line from STDIN , and strip them [code] auto line_st = line.strip(); [/code] However, I can't use result in another format routine. Assume my input line is "foobar": [code] writeln("Stripped line is %s",

Re: vibed services stop response after several days of work

2017-09-05 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:51:40 UTC, Sönke Ludwig wrote: The error is most likely caused by issuing two requests to the MySQL server from two different tasks on the same connection. Usually, mysql-native uses a connection pool to avoid this, but that could have been circumvented by

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:56:20 UTC, Andrea Fontana wrote: I used `lines(stdin)` as in https://dlang.org/phobos/std_stdio.html#.lines . My source code is here https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 . Thanks for your support. I think formattedRead is