Re: Is there a more elegant way to do this in D?

2021-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 4/7/21 8:57 PM, Brad wrote:     auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0]; I want to come out of this with a string that looks like this: 101110100 Me, me, me, me! :) import std; void main() { auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0]; string s = format!"%-(%s%)"(a); writeln(s); } Al

How Add DUB packages path to Dlang Linter to avoid Errors?

2021-04-07 Thread Marcone via Digitalmars-d-learn
When I import modules from dub im my SublimeText, D Linter show as errors. Example: 7:8 error dmd:Error module `core` is in file 'vibe\core\core.d' which cannot be read How solve it?

Re: Why I need DUB? Will never DMD don't just use import for import packages?

2021-04-07 Thread Alain De Vos via Digitalmars-d-learn
Here an example of using gtkd without dub : ldc2 -I/usr/local/include/d/gtkd-3 -L-lgtkd-3 -L-ldl hello.d When you run dub with parameters "--verbose" it informs you what is going on. I have not figured out how to use tkd without dub. It would be nice to know how.

Re: Database bindings

2021-04-07 Thread Alain De Vos via Digitalmars-d-learn
Now I see. I need to sort the packages by score. [ There are some dead monkeys in the package database ]

Re: Database bindings

2021-04-07 Thread mw via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 14:52:25 UTC, Alain De Vos wrote: Let's say I want to connect to the databases : - tokyokabinet - redis - mongodb - postgresql - sqlite - mysql - couchdb Which "dub add X" commands should I run for each of them ? https://code.dlang.org/search?q=database You need t

Re: Is this bug ? format %(%)

2021-04-07 Thread Meta via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote: On Wednesday, 7 April 2021 at 17:04:56 UTC, novice2 wrote: On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks

Re: Is this bug ? format %(%)

2021-04-07 Thread Berni44 via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:31:09 UTC, Paul Backus wrote: It's not your fault--this is a pretty obscure feature, and it's not documented very well. Even after you've found the correct page in the documentation (the page for `formattedWrite` [1]), you have to scroll down past multiple examp

Re: Is this bug ? format %(%)

2021-04-07 Thread Ali Çehreli via Digitalmars-d-learn
On 4/7/21 10:04 AM, novice2 wrote: On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to     writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks For the sake of completeness, I mention this feature in a couple of other places:

Re: Is this bug ? format %(%)

2021-04-07 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 17:04:56 UTC, novice2 wrote: On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks It's not your fault--this is a pretty obscure feature, and it

Re: Is this bug ? format %(%)

2021-04-07 Thread novice2 via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 13:43:18 UTC, Paul Backus wrote: So, you should change your code to writefln("%-(%s, %)", s); sorry i dont read docs so carefully thanks

Database bindings

2021-04-07 Thread Alain De Vos via Digitalmars-d-learn
Let's say I want to connect to the databases : - tokyokabinet - redis - mongodb - postgresql - sqlite - mysql - couchdb Which "dub add X" commands should I run for each of them ?

Re: Is this bug ? format %(%)

2021-04-07 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 13:31:59 UTC, novice3 wrote: there is extra quotes, wich not present in firmat specifier. is this bug, or i should change something in my code? This is actually an intentional feature (albeit kind of a stupid one). From the documentation: Inside a compound forma

Is this bug ? format %(%)

2021-04-07 Thread novice3 via Digitalmars-d-learn
https://run.dlang.io/is/p4NVp8 ```d void main() { import std.stdio: writefln; string[] s = ["a", "b", "c"]; writefln("%(%s, %)", s); } ``` output ```d "a", "b", "c" ``` expected ```d a, b, c ``` there is extra quotes, wich not present in firmat specifier. is this bug, or i should chan

Re: Read X many bytes from File to address Y

2021-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 12:57:12 UTC, tcak wrote: Well, I have a struct, that is defined as a variable already. I want to read X bytes from the file (not Struct.sizeof bytes though), and read into the struct variable without any extra buffer. file.rawRead((cast(ubyte*) &your_struct)[0 .

Re: Gui toolkits alive and gui toolkits dead

2021-04-07 Thread Alain De Vos via Digitalmars-d-learn
I meant dlang bindings.

Re: Read X many bytes from File to address Y

2021-04-07 Thread tcak via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 12:50:01 UTC, Adam D. Ruppe wrote: On Wednesday, 7 April 2021 at 11:42:56 UTC, tcak wrote: There is rawRead, but it takes an array as parameter, which causes a dirty looking code with cast etc! What did you wrote? file.rawRead(address[0 .. desiredLength]) shou

Re: Don't allow to reassign, but content is editable

2021-04-07 Thread Kagamin via Digitalmars-d-learn
struct A { private int[] a; this(int[] b){a=b;} int[] c(){ return a; } @disable void opAssign(); } struct B { A a; this(int){ a=new int[5]; } int[] b(){ return a.c; } void f(){ a=new int[5]; } }

Re: Read X many bytes from File to address Y

2021-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 11:42:56 UTC, tcak wrote: There is rawRead, but it takes an array as parameter, which causes a dirty looking code with cast etc! What did you wrote? file.rawRead(address[0 .. desiredLength]) should do what you want.

Re: Don't allow to reassign, but content is editable

2021-04-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 7 April 2021 at 12:28:25 UTC, tcak wrote: @property auto b(){ return a.ptr; } // this is a possibility, but results with overhead of calling. Also, b is not an array anymore, just int*. Why are you returning a.ptr instead of just a? If you return just a, it works fine for w

Don't allow to reassign, but content is editable

2021-04-07 Thread tcak via Digitalmars-d-learn
In javascript, with "const" keyword, you assign an object to a variable. Later, you cannot assign anything else to that variable, but content of it still can be changed. No matter by using "immutable" or "const", I cannot imitate that. Is there a way to do this without an overhead (like calling

Read X many bytes from File to address Y

2021-04-07 Thread tcak via Digitalmars-d-learn
I am talking about std.file.File. I have opened the file, and at a specific offset. I want to read X many bytes from the file, and want it to be written to given address directly without any Magical D-stuff like ranges etc. Is there a way to do this without getting into C or Posix header fi

Re: Vibe.d tutorial

2021-04-07 Thread M.M. via Digitalmars-d-learn
On Friday, 2 April 2021 at 22:29:20 UTC, Imperatorn wrote: On Thursday, 4 March 2021 at 13:47:11 UTC, Imperatorn wrote: On Monday, 1 March 2021 at 22:25:39 UTC, Rey Valeza wrote: Hi, I wrote a tutorial on Vibe.d while trying to re-learn Vibe.d. I find that most of Kai Nacke's book need updating

Re: Gui toolkits alive and gui toolkits dead

2021-04-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-04-06 21:57, Alain De Vos wrote: Can we say tk ang gtk toolkits are alive. But wxwidgets , fox an fltk are dead ? Do you mean these libraries in general or D bindings to these libraries? -- /Jacob Carlborg