Re: I like dlang but i don't like dub

2022-03-18 Thread Cym13 via Digitalmars-d-learn
On Friday, 18 March 2022 at 04:13:36 UTC, Alain De Vos wrote: Dlang includes some good ideas. But dub pulls in so much stuff. Too much for me. I like things which are clean,lean,little,small. But when i use dub it links with so many libraries. Are they really needed ? And how do you compare to py

Re: I need an Easy example to understand Alias This

2020-07-07 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 00:44:32 UTC, Marcone wrote: On Tuesday, 7 July 2020 at 00:42:40 UTC, Ali Çehreli wrote: On 7/6/20 5:35 PM, Marcone wrote: Hi, I study Dlang for one year, and I can't understand alias this. I need an Easy example to understand Alias This. Is the following example us

Re: Program exited with code -11 when calling

2020-06-30 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 05:04:28 UTC, Anthony wrote: I'm trying to convert this c function: bson_t *bson_new_from_json (const uint8_t *data, ssize_t len, bson_error_t *error); Into a D function. This is my attempt: extern(C) { struct bson_t; struct bson_error_t; bson_t* bso

Re: weekly news?

2020-01-22 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 18:53:49 UTC, mark wrote: Is there a "D weekly news" I could do an email subscription to? Or at least a way to get notified by email when a new item appears on https://dlang.org/blog/ ? There's http://dpldocs.info/this-week-in-d/Blog.html which is unofficial b

Re: Speed of Random Numbers

2019-08-03 Thread Cym13 via Digitalmars-d-learn
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria wrote: Hi to everybody I am doing some experiments about random numbers. I need "extreme speed" for the generation for numbers from 1 to 8. Generating 500_000_000 numbers with this code: - import std.s

Re: Question on Password Encryption, using stdlib or third party lib

2019-07-29 Thread Cym13 via Digitalmars-d-learn
On Monday, 29 July 2019 at 14:37:54 UTC, 0x wrote: On a project I was asked to a- Compute SHA-256 of a password b- Do a BigInteger, convert to Hex String c- Encrypt the key using a public key with the following parameters Entropy: I'm given some numbers Modulus: also given long num

Re: To learn D

2019-07-05 Thread Cym13 via Digitalmars-d-learn
On Friday, 5 July 2019 at 12:00:15 UTC, Binarydepth wrote: I've considering learning full D. I remembered that D is not recommended as a first language, So I read time ago. So my question, is learning C and Python a good intro before learning D? TY Both C and Python provide valuable and co

Re: Closures and memory allocation

2019-06-22 Thread Cym13 via Digitalmars-d-learn
On Saturday, 22 June 2019 at 19:26:13 UTC, Cym13 wrote: On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: [...] Clearly this is a good time for you to learn about the tools D offers to profile allocations. There is the --profile=gc DMD argument that you can use but here there's so

Re: Closures and memory allocation

2019-06-22 Thread Cym13 via Digitalmars-d-learn
On Saturday, 22 June 2019 at 16:52:07 UTC, Anonymouse wrote: I'm looking into why my thing does so many memory allocations. Profiling with kcachegrind shows _d_allocmemory being called upon entering a certain function, lots and lots of times. It's a function that receives concurrency messages,

Re: make C is scriptable like D

2019-06-20 Thread Cym13 via Digitalmars-d-learn
On Thursday, 20 June 2019 at 06:20:17 UTC, dangbinghoo wrote: hi there, a funny thing: $ cat rgcc #!/bin/sh cf=$@ mycf=__`echo $cf|xargs basename` cat $cf | sed '1d' > ${mycf} gcc ${mycf} -o a.out rm ${mycf} ./a.out $ cat test.c #!/home/user/rgcc #include int

Re: Where can find fix length array memory layout document

2019-06-19 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 05:27:12 UTC, lili wrote: On Tuesday, 18 June 2019 at 17:29:49 UTC, Cym13 wrote: On Tuesday, 18 June 2019 at 17:25:42 UTC, Cym13 wrote: On Tuesday, 18 June 2019 at 13:05:03 UTC, lili wrote: On Tuesday, 18 June 2019 at 12:39:45 UTC, Dennis wrote: [...] Thanks a l

Re: Where can find fix length array memory layout document

2019-06-18 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 17:25:42 UTC, Cym13 wrote: On Tuesday, 18 June 2019 at 13:05:03 UTC, lili wrote: On Tuesday, 18 June 2019 at 12:39:45 UTC, Dennis wrote: [...] Thanks a lot, where is a core.stdcpp.array , How to user it? I test but get a error ``` auto aa = array!(int, 4); //erro

Re: Where can find fix length array memory layout document

2019-06-18 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 13:05:03 UTC, lili wrote: On Tuesday, 18 June 2019 at 12:39:45 UTC, Dennis wrote: On Tuesday, 18 June 2019 at 12:26:14 UTC, lili wrote: [...] I'm assuming you mean writeln([1].sizeof). An array literal is a slice of a dynamic array (which is length + pointer,

Re: What does ! Stand for in map! and filter! function calls?

2019-06-02 Thread Cym13 via Digitalmars-d-learn
On Sunday, 2 June 2019 at 15:48:54 UTC, Rnd wrote: I have recently started using Dlang, hence this basic question. Thanks for your insight. To know more about D you should take the time to do the D tour [1] which provides you with general knowledge of most of D's functionalities and vocabular

Re: Why GNU coreutils/dd is creating a dummy file more efficiently than D's For loop?

2019-05-23 Thread Cym13 via Digitalmars-d-learn
On Thursday, 23 May 2019 at 09:09:05 UTC, BoQsc wrote: This code of D creates a dummy 47,6 MB text file filled with Nul characters in about 9 seconds import std.stdio, std.process; void main() { writeln("Creating a dummy file"); File file = File("test.txt", "w"); for (int

Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread Cym13 via Digitalmars-d-learn
On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote: Hi, I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+. I had a look at Pyd but it's limited to python 2.7... Would there be other ways to call python functions and retrieve the python objects

Re: [windows] Can't delete a closed file?

2019-05-10 Thread Cym13 via Digitalmars-d-learn
On Friday, 10 May 2019 at 15:06:46 UTC, Temtaime wrote: Lol, you don't have to load and unload the curl dll. std.net.curl have its own lazy libcurl loader. But i'm not sure if it tries to find the dll in the temp directory. If it is the case, then it simply doesn't unload the dll when you have

Re: In what situation can new Struct() return null?

2019-05-10 Thread Cym13 via Digitalmars-d-learn
On Friday, 10 May 2019 at 10:11:51 UTC, faissaloo wrote: My program contains the following statement: auto newChildNode = new Node(); In debugging I have found that this pointer evaluates to null, what could cause this? I should have plenty of memory, my only other idea is some sort of hea

Re: [windows] Can't delete a closed file?

2019-05-10 Thread Cym13 via Digitalmars-d-learn
On Friday, 10 May 2019 at 07:09:45 UTC, Seb wrote: On Thursday, 9 May 2019 at 13:18:44 UTC, Cym13 wrote: On Thursday, 9 May 2019 at 13:02:51 UTC, Rene Zwanenburg wrote: On Thursday, 9 May 2019 at 12:33:37 UTC, Cym13 wrote: [...] You could try to use the find handle function in Process Explo

Re: [windows] Can't delete a closed file?

2019-05-10 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 May 2019 at 15:05:10 UTC, Andre Pany wrote: Can you reproduce the issue with other Dlls or is it only reproducible with curl dll? Does the issue with curl dll also exists if you do not call the curl function? Kind regards Andre I didn't have the time to test with another dll j

Re: [windows] Can't delete a closed file?

2019-05-09 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 May 2019 at 13:02:51 UTC, Rene Zwanenburg wrote: On Thursday, 9 May 2019 at 12:33:37 UTC, Cym13 wrote: On Thursday, 9 May 2019 at 11:31:20 UTC, Cym13 wrote: ... To dismiss any doubt about AV or other processes coming into play I took the binary and ran it with wine on linux wi

Re: [windows] Can't delete a closed file?

2019-05-09 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 May 2019 at 11:31:20 UTC, Cym13 wrote: ... To dismiss any doubt about AV or other processes coming into play I took the binary and ran it with wine on linux with the exact same end result. For reference my windows system is a 64b windows 10.

Re: [windows] Can't delete a closed file?

2019-05-09 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 May 2019 at 11:07:53 UTC, Andre Pany wrote: On Thursday, 9 May 2019 at 10:09:23 UTC, Cym13 wrote: Hi, this is likely not related to D itself but hopefully someone can help me with this since I'm rather new to windows programming, I mainly work on linux. I'm trying to bundle a

Re: [windows] Can't delete a closed file?

2019-05-09 Thread Cym13 via Digitalmars-d-learn
On Thursday, 9 May 2019 at 11:11:56 UTC, Rumbu wrote: Since deploying a dll is a suspect behaviour outside a normal installation process, most probably you have a lock on the file put by windows defender or an antivirus if installed. Thanks for your input but I'm absolutely certain that it's n

[windows] Can't delete a closed file?

2019-05-09 Thread Cym13 via Digitalmars-d-learn
Hi, this is likely not related to D itself but hopefully someone can help me with this since I'm rather new to windows programming, I mainly work on linux. I'm trying to bundle a DLL in a binary, write it in a temp folder, use it and remove the dangling file. So far I have the following file

Re: Erasing passwords from ram?

2019-05-06 Thread Cym13 via Digitalmars-d-learn
On Monday, 6 May 2019 at 09:34:22 UTC, Dukc wrote: Oops, I forgot to check back this theard. But yes, just the info I was looking for. On Wednesday, 1 May 2019 at 22:14:52 UTC, Cym13 wrote: There are very few relevant threat models where removing a password from RAM is an adequate solution.

Re: Erasing passwords from ram?

2019-05-01 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 30 April 2019 at 08:15:15 UTC, Dukc wrote: I am currently programming a server. So I got the idea that after I've generated all the hashes I need from a password, I want to erase it from RAM before discarding it, just to be sure it won't float around if the server memory is exposed

Re: Does D have a tool like pySnooper?

2019-04-27 Thread Cym13 via Digitalmars-d-learn
On Monday, 22 April 2019 at 16:24:53 UTC, Taylor Hillegeist wrote: Saw this tool and thought D could probably do something like this pretty easily. Is there such a tool out there already? https://github.com/cool-RR/pysnooper Or would this not be easy at all with D? First line of that link: "

Re: Chat using Socket and Thread

2019-04-24 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 23 April 2019 at 22:02:59 UTC, Allison wrote: How to make a chat for several users chat? Using socket and thread. First of all, there are many tutorials on the internet covering that exact topic for different languages. I don't think there are many tutorials for D, but you should

Re: Future of D language

2019-04-23 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 24 April 2019 at 05:22:35 UTC, Arjunkumar wrote: I am title bit confuse about learning D Lang and is it well good for future point of view. Currently in a market many of language is present, so why people learn D Lang and any site which provide best tutorials for D Lang? The rea

DRuntime arguments

2019-04-10 Thread Cym13 via Digitalmars-d-learn
Where can I find a list of all druntime arguments supported? Things like --DRT-covopt='merge:1' or --DRT-gcopt='gc:profile=1' are not easy to guess and I can't find any centralized documentation.

Re: Iterate/sort associative array by value?

2019-04-07 Thread Cym13 via Digitalmars-d-learn
On Sunday, 7 April 2019 at 15:41:51 UTC, Robert M. Münch wrote: I have an AA int[ulong] and would like to traverse the AA from biggest to smallest by value. Is there an elegant way to do this? The only way I can imagine is to create an "reverse" AA of the form ulong[int] and than sort by keys

Re: Why does D language do not support BigDecimal type?

2019-03-12 Thread Cym13 via Digitalmars-d-learn
On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote: There is Money datatype that can be provided by using a third party package: https://code.dlang.org/packages/money But that's only for money, what about math? Why such fundamental as BigDecimal is still not included into the D language its

Re: Executing a D script without an [extension in the filename] leads to an error

2019-03-01 Thread Cym13 via Digitalmars-d-learn
On Friday, 1 March 2019 at 11:38:51 UTC, BoQsc wrote: On Friday, 1 March 2019 at 09:27:33 UTC, Cym13 wrote: On Friday, 1 March 2019 at 09:00:43 UTC, BoQsc wrote: I've installed D compiler, and when i try to run a D script with filename without an extension/file type named: program via: ./prog

Re: Executing a D script without an [extension in the filename] leads to an error

2019-03-01 Thread Cym13 via Digitalmars-d-learn
On Friday, 1 March 2019 at 14:50:45 UTC, Jesse Phillips wrote: On Friday, 1 March 2019 at 11:38:51 UTC, BoQsc wrote: "And indeed rdmd won't call your script if it doesn't have the proper extension." Then why does Dlang Tour includes shebang: #!/usr/bin/env rdmd Instead of the one you mentione

Re: Executing a D script without an [extension in the filename] leads to an error

2019-03-01 Thread Cym13 via Digitalmars-d-learn
On Friday, 1 March 2019 at 09:00:43 UTC, BoQsc wrote: I've installed D compiler, and when i try to run a D script with filename without an extension/file type named: program via: ./program I'm getting and error: vaidas@SATELLITE-L855:~/Desktop$ ./program Error: module `program` is in file './

Re: Process Information

2019-02-23 Thread Cym13 via Digitalmars-d-learn
On Saturday, 23 February 2019 at 20:49:49 UTC, r-const-dev wrote: Is there a way to get information about the current process? Memory usage, CPU usage, PID. The PID is easy, from std.process it's a standard function call away: https://dlang.org/phobos/std_process.html#.thisProcessID I don't

Re: Should D file end with newline?

2019-02-10 Thread Cym13 via Digitalmars-d-learn
On Sunday, 10 February 2019 at 02:12:43 UTC, Jonathan M Davis wrote: On Saturday, February 9, 2019 2:19:27 PM MST Victor Porton via Digitalmars- d-learn wrote: ISO C++ specifies that the C++ file must end with a newline. Should D file end with newline, too? No, there is no need to end D files

Re: Prime number

2018-08-06 Thread Cym13 via Digitalmars-d-learn
On Thursday, 2 August 2018 at 14:37:56 UTC, Greatsam4sure wrote: On Thursday, 2 August 2018 at 09:35:20 UTC, Cym13 wrote: On Thursday, 2 August 2018 at 08:30:05 UTC, Greatsam4sure wrote: I know D is very powerful from my little experience. What is the idiomatic way to get prime numbers say from

Re: Prime number

2018-08-02 Thread Cym13 via Digitalmars-d-learn
On Thursday, 2 August 2018 at 08:30:05 UTC, Greatsam4sure wrote: I know D is very powerful from my little experience. What is the idiomatic way to get prime numbers say from 1-30 without using loops(outer and inner loop). Can map, filter, fold etc in algorithm be use. Pls show some code with c

Re: Dynamic arrays / ~= giving an exception...

2018-07-01 Thread Cym13 via Digitalmars-d-learn
On Sunday, 1 July 2018 at 20:55:16 UTC, Robert M. Münch wrote: I'm a bit puzzled because I think this is pretty straight forward but doesn't work... struct mystruct { myPtr* root; opApply(...){ myPtr*[] childs; childs ~= root;

Re: Zip vs Enumerate

2018-06-19 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 04:40:42 UTC, Cym13 wrote: On Wednesday, 20 June 2018 at 03:44:58 UTC, Jordan Wilson wrote: [...] This sounds like a very limited case: if you're not zipping against a iota(foo) then there's no comparing with enumerate, they simply don't do the same thing at all

Re: Zip vs Enumerate

2018-06-19 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 20 June 2018 at 03:44:58 UTC, Jordan Wilson wrote: Hello, Idiomatically, I make use of zip, however, when looking to speed up my program, notice that using enumerate leads to a 20-30% improvement: void main(){ auto x = iota(1_000).array; auto y = iota(1_000).array;

Re: Create a List or Dictionary.

2018-06-19 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 19 June 2018 at 05:52:00 UTC, Sunny wrote: On Monday, 18 June 2018 at 13:23:37 UTC, Cym13 wrote: Yes, this is what need, thank you very much for your help. :-) [...] I recommend that you take the D tour if you can, it explains all those fundamental features quite well I think.

Re: Create a List or Dictionary.

2018-06-18 Thread Cym13 via Digitalmars-d-learn
On Monday, 18 June 2018 at 11:44:43 UTC, Sunny wrote: Hello, I'm having a problem, how can I create a List or Dictionary in D? In C #, I can create a tuple list, example: var musicList = new List <(string URL, string Artist, string Title, string Cover, string Duration)> (); In Google did no

Re: WTF! new in class is static?!?!

2018-06-07 Thread Cym13 via Digitalmars-d-learn
On Thursday, 7 June 2018 at 21:07:26 UTC, DigitalDesigns wrote: class A; class B { A a = new A(); } auto b1 = new B(); auto b2 = new B(); assert(b1.a == b2.a)!! I'm glad I finally found this out! This is not typical behavior in most languages is it? I'd expect it to be translated to so

Re: dynamically allocating on the stack

2018-04-22 Thread Cym13 via Digitalmars-d-learn
On Sunday, 22 April 2018 at 05:29:30 UTC, Mike Franklin wrote: On Sunday, 22 April 2018 at 00:41:34 UTC, Nicholas Wilson wrote: You're not using the C library version of it, the compiler does the stack space reservation inline for you. There is no way around this. I'm not convinced. I did s

Re: dynamically allocating on the stack

2018-04-21 Thread Cym13 via Digitalmars-d-learn
On Saturday, 21 April 2018 at 13:30:55 UTC, Cym13 wrote: [...] Nevermind, forgot that shared libraries are put between the two.

Re: dynamically allocating on the stack

2018-04-21 Thread Cym13 via Digitalmars-d-learn
On Saturday, 21 April 2018 at 13:54:14 UTC, H. S. Teoh wrote: On Sat, Apr 21, 2018 at 01:30:55PM +, Cym13 via Digitalmars-d-learn wrote: On Saturday, 21 April 2018 at 12:08:09 UTC, Dmitry Olshansky wrote: [...] > Unbounded allocation on stack is kind of anti-pattern and a > potenti

Re: dynamically allocating on the stack

2018-04-21 Thread Cym13 via Digitalmars-d-learn
On Saturday, 21 April 2018 at 12:08:09 UTC, Dmitry Olshansky wrote: On Saturday, 21 April 2018 at 07:37:50 UTC, Mike Franklin wrote: Does D have some way to dynamically allocate on the stack? I'm looking for something roughly equivalent to the following C code. int doSomething(size_t len) {

Re: Passing directory as compiler argument not finding file

2018-04-13 Thread Cym13 via Digitalmars-d-learn
On Friday, 13 April 2018 at 13:39:23 UTC, Tony wrote: On Friday, 13 April 2018 at 12:46:32 UTC, Cym13 wrote: On Friday, 13 April 2018 at 01:27:06 UTC, Tony wrote: I think that the typical model (at least in other languages) is to only compile one D source file at a time. Compile the b.d file w

Re: Passing directory as compiler argument not finding file

2018-04-13 Thread Cym13 via Digitalmars-d-learn
On Friday, 13 April 2018 at 01:27:06 UTC, Tony wrote: I think that the typical model (at least in other languages) is to only compile one D source file at a time. Compile the b.d file with the -c option to create an object file. Then put the object file in a library file (either static (easier)

Re: Range length property

2018-04-10 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 20:08:14 UTC, Jonathan M Davis wrote: On Tuesday, April 10, 2018 19:47:10 Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote: > On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote: >> Should ranges always provid

Re: Strange Thread Causing Duplicating `writeln`

2018-04-09 Thread Cym13 via Digitalmars-d-learn
On Monday, 9 April 2018 at 22:28:45 UTC, Jonathan wrote: I am totally lost on why this is happening. I stripped the code down to what appears to be the most minimal code that still causes the problem. --- import core.sync.mutex; import core.thread; import std.stdio; __gshared Mutex m;//__gsh

Re: Declare and Define Before Use? [rant]

2018-04-04 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 19:51:27 UTC, kdevel wrote: On Wednesday, 4 April 2018 at 19:19:30 UTC, Ali wrote: On Wednesday, 4 April 2018 at 18:57:27 UTC, kdevel wrote: [...] I think the rules should have been the same everywhere and if there was an exception to be made, it could be made for

Re: Fix transposed ranges

2018-04-02 Thread Cym13 via Digitalmars-d-learn
On Monday, 2 April 2018 at 19:45:31 UTC, Steven Schveighoffer wrote: On 4/2/18 3:24 PM, Cym13 wrote: [...] Well, it's tough, because you can compose ranges in infinite ways. All you need to generate the warning is some code like this: [...] That makes sense, thanks.

Re: Fix transposed ranges

2018-04-02 Thread Cym13 via Digitalmars-d-learn
On Monday, 2 April 2018 at 18:33:25 UTC, Steven Schveighoffer wrote: On 3/30/18 4:45 PM, Cym13 wrote: On Friday, 30 March 2018 at 20:43:09 UTC, Cym13 wrote: Hi, I've got the following code that takes a list of files as argument and xor them together (demo example sufficient for that discussion

Re: Optional parameters?

2018-04-02 Thread Cym13 via Digitalmars-d-learn
On Monday, 2 April 2018 at 09:31:35 UTC, Timoses wrote: On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer wrote: I currently have a situation where I want to have a function that accepts a parameter optionally. I thought maybe Nullable!int might work: void foo(Nullable!int) {} vo

Re: Fix transposed ranges

2018-03-30 Thread Cym13 via Digitalmars-d-learn
On Friday, 30 March 2018 at 20:43:09 UTC, Cym13 wrote: Hi, I've got the following code that takes a list of files as argument and xor them together (demo example sufficient for that discussion). [...] Forgot to mention but I'm also quite annoyed at the need for that ".array" because "transp

Fix transposed ranges

2018-03-30 Thread Cym13 via Digitalmars-d-learn
Hi, I've got the following code that takes a list of files as argument and xor them together (demo example sufficient for that discussion). import std.stdio; import std.array; import std.range; import std.algorithm; auto rawContent(string path) { return File(path).b

Re: string to hex convert

2018-03-29 Thread Cym13 via Digitalmars-d-learn
On Thursday, 29 March 2018 at 20:29:39 UTC, aerto wrote: how i can convert Hello world! to hex 48656c6c6f20776f726c6421 ?? Maybe something like: void main() { // Those look like lots of imports but most of those are very common anyway import std.digest: toHexString; import std.st

Re: What is the "right" way to create a generic type getter (and setter) ?

2018-03-15 Thread Cym13 via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:48:52 UTC, James Blachly wrote: On Wednesday, 14 March 2018 at 22:58:25 UTC, ag0aep6g wrote: You can probably get around the (manually maintained?) `FIELDS` array with `.tupleof` or something similar: static foreach (i, f; S.tupleof) { case __traits(id

Re: Equivalent to Python with Statement

2018-02-28 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 28 February 2018 at 22:55:19 UTC, Seb wrote: On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote: On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote: I know Python's `with` statement can be used to have an automatic close action: ``` with open("x.txt") as fi

Re: Equivalent to Python with Statement

2018-02-28 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote: I know Python's `with` statement can be used to have an automatic close action: ``` with open("x.txt") as file: #do something with file #`file.close()` called automatically ``` I know D's `with` statement does somethi

Re: countUntil to print all the index of a given string.

2018-02-18 Thread Cym13 via Digitalmars-d-learn
On Sunday, 18 February 2018 at 14:48:59 UTC, Cym13 wrote: [...] Just thought of a much better/simpler solution for that last case that also doesn't force you to read all data (which might be impossible when dealing with infinite ranges): import std.range; import std.algorithm;

Re: countUntil to print all the index of a given string.

2018-02-18 Thread Cym13 via Digitalmars-d-learn
On Sunday, 18 February 2018 at 11:55:37 UTC, Vino wrote: Hi All, Request your help on printing the all index of an array element , eg; the below code prints the index of the string "Test2" as [1], but the string "Test2" is present 2 times at index 1 and 4, so how do I print all the index

Re: [Help] programm execution leads to infinity background loop after... what reason?

2018-02-11 Thread Cym13 via Digitalmars-d-learn
On Sunday, 11 February 2018 at 17:28:25 UTC, Eld0r wrote: changed my design from extending thread to just using taskPool.parallel. seems like my implementation left to many open threads in background and forcing the operation system to cut them off. thought start() and join() allowed me to use

Re: Caesar Cipher

2018-02-11 Thread Cym13 via Digitalmars-d-learn
On Sunday, 11 February 2018 at 18:50:25 UTC, Mario wrote: On Sunday, 11 February 2018 at 18:31:35 UTC, Seb wrote: On Sunday, 11 February 2018 at 18:01:20 UTC, Mario wrote: Hello there! I know deep Java, JavaScript, PHP, etc. but as you all probably know, that's high-level and most of them only

Re: Caesar Cipher

2018-02-11 Thread Cym13 via Digitalmars-d-learn
On Sunday, 11 February 2018 at 18:01:20 UTC, Mario wrote: Hello there! I know deep Java, JavaScript, PHP, etc. but as you all probably know, that's high-level and most of them only use the heap memory. So I'm new to the wonderful world of low-level and the stack-heap. I started a week ago lea

Re: Create D portable binary

2017-12-08 Thread Cym13 via Digitalmars-d-learn
On Friday, 8 December 2017 at 06:37:36 UTC, Adam D. Ruppe wrote: On Friday, 8 December 2017 at 05:16:22 UTC, Fra Mecca wrote: Is there a way to compile a project and deploying it as a single statically linked binary? A default build of a D program is *reasonably* compatible. All its dependenc

Re: Binary serialization of a struct

2017-12-08 Thread Cym13 via Digitalmars-d-learn
On Saturday, 16 September 2017 at 13:15:54 UTC, Azi Hassan wrote: On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of al

Re: Getting a safe path for a temporary file

2017-10-25 Thread Cym13 via Digitalmars-d-learn
On Sunday, 18 January 2015 at 00:51:37 UTC, Laeeth Isharc wrote: On Saturday, 17 January 2015 at 16:55:42 UTC, Marc Schütz wrote: On Saturday, 17 January 2015 at 14:37:00 UTC, Laeeth Isharc wrote: On Saturday, 17 January 2015 at 13:47:39 UTC, Marc Schütz wrote: [...] I agree that it would be

Re: Getting a safe path for a temporary file

2017-10-25 Thread Cym13 via Digitalmars-d-learn
On Sunday, 18 January 2015 at 16:00:32 UTC, Kagamin wrote: On Sunday, 18 January 2015 at 11:21:52 UTC, Marc Schütz wrote: It's not different, and if you're still doing the O_EXCL open afterwards, it's safe. I just assumed you were going to use the generated filename without a further check. Thi

Re: Valid File Path

2017-08-31 Thread Cym13 via Digitalmars-d-learn
On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote: Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("P

Re: Why D have two function contains and canFind?

2017-07-24 Thread Cym13 via Digitalmars-d-learn
On Monday, 24 July 2017 at 18:31:09 UTC, Ali Çehreli wrote: On 07/24/2017 11:19 AM, Suliman wrote: > [...] only > [...] std.algorithm.canFind and std.range.SortedRange.contains: [...] I'm gessing this predates design by introspection as it would be cleaner to let the compiler do the switch i

Re: criando modulos em D para classe pessoa[AJUDA]

2017-07-24 Thread Cym13 via Digitalmars-d-learn
On Monday, 24 July 2017 at 19:45:03 UTC, dark777 wrote: pessoal eu tenho umas classes java e estava portando para D e para usar as importaçoes criei os modules nescessarios todos estao dentro da mesma pasta porem ao fazer: $rdmd principal ele retorna o seguinte erro: principal.d(18): Error:

Re: How to add authentificaion method to request?

2017-07-12 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 07:43:27 UTC, Suliman wrote: Compiler require libssl32.dll for run dlang-request based app. Where I can get it? I installed, OpenSSL, but can't find this lib in C:\OpenSSL-Win64 I don't use windows so it's nothing definitive but I'd bet that the "32" in libssl3

Re: dmd, vibe.d RAM usage when compiling.

2017-07-11 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 16:04:52 UTC, SrMordred wrote: I never notice this before, but i tried to put a basic hello world from vibe.d (like the one that are in the dlang front page examples now), into the most basic instance on google cloud (with 600mb of RAM) and the compilation returned

Re: How to add authentificaion method to request?

2017-07-11 Thread Cym13 via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 12:15:39 UTC, Suliman wrote: I am using dlang-requests. I need authentificate on https://scihub.copernicus.eu/dhus/login and than do some data-parsing. MultipartForm form; form.add(formData("login_username", "Suliman")); form.add(formData("login_password

Re: Application settings

2017-07-07 Thread Cym13 via Digitalmars-d-learn
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it,

Re: How to get uniq to return an array?

2017-07-04 Thread cym13 via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 11:00:05 UTC, PumpkinCake wrote: I'm trying to strip repeated values out of an int array using uniq. It's returning a UniqResult which can't be accessed like an array... how can I get it to return an array, or cast whatever it is returning to be an array? Most funct

Re: Advice wanted on garbage collection of sockets for c++ programmer using D

2017-06-27 Thread cym13 via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 12:29:03 UTC, Guillaume Piolat wrote: [...] Hmm... Isn't it possible to just allocate the object/a pool of objects outside the loop and reuse it? Everybody's proposing other means of allocations which is nice, but I wonder why there is such a need for reallocation

Re: Dealing with the interior pointers bug

2017-06-22 Thread Cym13 via Digitalmars-d-learn
On Thursday, 22 June 2017 at 18:38:59 UTC, Boris-Barboris wrote: On Thursday, 22 June 2017 at 13:56:29 UTC, ag0aep6g wrote: For example, the type system guarantees that immutable data never changes. But the compiler allows you to cast from immutable to mutable and change the data. It's an inval

Re: GDC generate wrong .exe ("not a valid win32 application")

2017-06-21 Thread cym13 via Digitalmars-d-learn
On Thursday, 22 June 2017 at 05:57:59 UTC, bauss wrote: On Wednesday, 21 June 2017 at 15:55:27 UTC, David Nadlinger wrote: On Monday, 19 June 2017 at 14:08:56 UTC, Patric Dexheimer wrote: Fresh install of GDC. (tried with 32x ad 32_64x) Where did you get the GDC executable from? The GDC proje

Re: Dealing with the interior pointers bug

2017-06-21 Thread Cym13 via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 17:11:41 UTC, TheGag96 wrote: On Wednesday, 21 June 2017 at 15:42:22 UTC, Adam D. Ruppe wrote: This comes from the fact that D's GC is conservative - if it sees something that *might* be a pointer, it assumes it *is* a pointer and thus had better not get freed. S

Re: libc dependency

2017-06-19 Thread Cym13 via Digitalmars-d-learn
On Monday, 19 June 2017 at 21:01:35 UTC, Honey wrote: On Monday, 19 June 2017 at 20:26:43 UTC, Adam D. Ruppe wrote: On Monday, 19 June 2017 at 20:20:23 UTC, Honey wrote: Is it correct that D produces executables that depend on libc? Usually yes, since that makes sense for most programs on op

Re: Simple c header => Dlang constants using mixins in compile time

2017-06-17 Thread Cym13 via Digitalmars-d-learn
On Saturday, 17 June 2017 at 11:20:53 UTC, Igor Shirkalin wrote: On Saturday, 17 June 2017 at 11:10:47 UTC, Igor wrote: On Saturday, 17 June 2017 at 10:56:52 UTC, Igor Shirkalin wrote: Hello! I have a simple C header file that looks like: #define Name1 101 #define Name2 122 #define NameN

Re: byLine(n)?

2017-06-11 Thread Cym13 via Digitalmars-d-learn
On Sunday, 11 June 2017 at 12:44:05 UTC, helxi wrote: On Sunday, 11 June 2017 at 06:28:18 UTC, Stanislav Blinov wrote: On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote: [...] You need only the nth line? Then you'd need to `drop` the preceding ones: void main(string[] args) { import

Re: byLine(n)?

2017-06-11 Thread Cym13 via Digitalmars-d-learn
On Sunday, 11 June 2017 at 08:33:16 UTC, Cym13 wrote: On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote: [...] Ok, if I read you right you are writing to stdin and want first to print the first args[1] lines, then to do other things with the other lines of stdin. [...] Meh... I just n

Re: byLine(n)?

2017-06-11 Thread Cym13 via Digitalmars-d-learn
On Sunday, 11 June 2017 at 05:36:08 UTC, helxi wrote: I was writing a program that reads and prints the first nth lines to the stdout: import std.stdio; void main(string[] args) { import std.algorithm, std.range; import std.conv; stdin.byLine.take(args[1].to!ulong).each!writeln; }

Re: How to Compare 2 objects of the same class

2017-06-03 Thread cym13 via Digitalmars-d-learn
On Saturday, 3 June 2017 at 20:02:13 UTC, Mark wrote: On Saturday, 3 June 2017 at 19:57:47 UTC, Mark wrote: Hello again. I'm designing a template version of a BST. Because of this, I want to be able to compare if two objects of the same class type are references to the same anonymous class o

Re: howto count lines - fast

2017-05-31 Thread cym13 via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 17:23:46 UTC, Ali Çehreli wrote: On 05/30/2017 11:50 PM, Daniel Kozak via Digitalmars-d-learn wrote: > How do you compile it? When I use ldc2 -O3 -release -mcpu=bdver1 lc.d > my code is even faster than wc My bad: I'm not familiar with ldc's optimization options.

Re: Finding the index of the maximum value in an associative array

2017-05-30 Thread cym13 via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 17:57:04 UTC, Lyle wrote: Hi, I have an associative array of type int[ulong] and I'm trying to get the index of the maximum value, like this: int[ulong] aa = [1UL: 2000, 2UL: 5000, 5UL: 1000]; writeln(aa.maxIndex); // should print

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread cym13 via Digitalmars-d-learn
On Friday, 12 May 2017 at 11:58:23 UTC, k-five wrote: On Friday, 12 May 2017 at 11:41:57 UTC, cym13 wrote: [...] --- [...] - Thanks and the correct syntax for each! is, passing a lambd

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread cym13 via Digitalmars-d-learn
On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: I was waiting for a stable version of C++17 ( standard library ) to add some features of fileSystem in C++17 to my program that wants to iterate through all files in a directory recursively. I was thinking how could I do for implementing t

Re: User input; quick question.

2017-04-29 Thread cym13 via Digitalmars-d-learn
On Saturday, 29 April 2017 at 21:09:13 UTC, fred wrote: import std.stdio; I am somewhat new to D, and I am trying to receive user input, like this, with a prompt: string str; writeln("Enter a string: "); str = readln; writeln(str); However, the prompt appears after I enter the input; any rea

Re: Get name of current function

2017-04-23 Thread cym13 via Digitalmars-d-learn
On Sunday, 23 April 2017 at 20:34:12 UTC, Mike B Johnson wrote: I'd like to get the symbolic name of the current function I'm in void foo() { writeln(thisFunc.stringof()); // prints foo } I need something short, elegant and doesn't require modifying preexisting code... I'm sure D has somet

Re: Why map return [] ?

2017-04-14 Thread cym13 via Digitalmars-d-learn
On Friday, 14 April 2017 at 15:29:33 UTC, Suliman wrote: auto x = MySQLTablesRange.map!(a=>a); writeln(x); return: [] while next code: MySQLTablesRange.each!(a=>a.writeln); return data line by line. Why? What library is that supposed to be?

Re: exceptions thrown when running app with failed unittests

2017-03-19 Thread cym13 via Digitalmars-d-learn
On Sunday, 19 March 2017 at 22:13:21 UTC, Ervin Bosenbacher wrote: Its my 2nd day into D, I am already in deep love (:D), and I would like to understand whether this is normal behavior or something went terribly wrong, so all help is greatly appreciated. [...] Well, unittests can pass or f

Re: RAII

2017-02-23 Thread cym13 via Digitalmars-d-learn
On Thursday, 23 February 2017 at 09:52:26 UTC, Arun Chandrasekaran wrote: I'm trying to write an RAII wrapper on Linux. I understand struct in D doesn't have default constructor (for .init reasons). I don't want to use `scope`. Is there an elegant way to achieve this in D? ``` import core.sy

  1   2   3   >