Re: Development: Work vs Lazy Programmers... How do you keep sanity?

2020-12-03 Thread Igor Shirkalin via Digitalmars-d-learn
On Thursday, 3 December 2020 at 15:18:31 UTC, matheus wrote: Hi, I didn't know where to post this and I hope this is a good place. I'm a lurker in this community and I read a lot of discussions on this forum and I think there a lot of smart people around here. So I'd like to know if any

Re: How to imporve D-translation of these Python list comprehensions ?

2018-01-15 Thread Igor Shirkalin via Digitalmars-d-learn
On Monday, 15 January 2018 at 19:05:52 UTC, xenon325 wrote: A workmate has recently shown this piece of code to show how nice Python is (we are mostly C and growing C++ shop): dd = [dict(_name=k, **{a + str(i): aget(d, k, a) for a in aa for i, d in enumerate([srv1, srv2])}) for k in

Re: Efficient way to pass struct as parameter

2018-01-02 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 18:45:48 UTC, Jonathan M Davis wrote: [...] Smart optimizer should think for you without any "auto" private words if function is inlined. I mean LDC compiler first of all.

Re: Why 2 ^^ 1 ^^ 2 = 2?

2017-11-01 Thread Igor Shirkalin via Digitalmars-d-learn
On Sunday, 22 October 2017 at 14:20:20 UTC, Ilya Yaroshenko wrote: .. i thought it should be (2 ^^ 1) ^^ 2 = 4 Imagine 2^^10^^10^^7. It's a big number, isn't? (up-up-and up) Where would you start from?

Re: "version" private word

2017-10-31 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 15:19:49 UTC, Steven Schveighoffer wrote: On 10/31/17 10:47 AM, Igor Shirkalin wrote: [...] Sorry I hate writing code on mobile. You can create an arbitrary version by assigning a symbol to it, use that symbol to describe a feature, assign that symbol for

Re: "version" private word

2017-10-31 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 14:54:27 UTC, Dr. Assembly wrote: On Tuesday, 31 October 2017 at 13:53:54 UTC, Jacob Carlborg wrote: On 2017-10-31 14:46, Igor Shirkalin wrote: [...] The only alternative is to do something like this: version (X86) enum x86 = true; else enum x86 =

Re: "version" private word

2017-10-31 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 14:31:17 UTC, Jesse Phillips wrote: On Tuesday, 31 October 2017 at 14:25:19 UTC, Igor Shirkalin wrote: On Tuesday, 31 October 2017 at 14:22:37 UTC, Jesse Phillips wrote: On Tuesday, 31 October 2017 at 13:46:40 UTC, Igor Shirkalin wrote: Hello! You goal should

Re: "version" private word

2017-10-31 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 14:22:37 UTC, Jesse Phillips wrote: On Tuesday, 31 October 2017 at 13:46:40 UTC, Igor Shirkalin wrote: Hello! You goal should be to describe features. Version x86 ... Version = I can stand on my head ... pardon?

Re: "version" private word

2017-10-31 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 13:53:54 UTC, Jacob Carlborg wrote: On 2017-10-31 14:46, Igor Shirkalin wrote: Hello! We need some conditional compilation using 'version'. Say we have some code to be compiled for X86 and X86_64. How can we do that using predefined (or other) versions? Examples:

"version" private word

2017-10-31 Thread Igor Shirkalin via Digitalmars-d-learn
Hello! We need some conditional compilation using 'version'. Say we have some code to be compiled for X86 and X86_64. How can we do that using predefined (or other) versions? Examples: version(X86 || X86_64) // failed version(X86) || version(X86_64) // failed The following works but it

Re: the best language I have ever met(?)

2017-10-10 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 25 November 2016 at 19:16:43 UTC, ketmar wrote: yeah. but i'm not Andrei, i don't believe that the only compiler task is to resolve templated code. ;-) i.e. Andrei believes that everything (and more) should be moved out of compiler core and done with library templates. Andrei is

Re: Why do I have to cast arguments from int to byte?

2017-10-10 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 19:55:36 UTC, Chirs Forest wrote: I keep having to make casts like the following and it's really rubbing me the wrong way: void foo(T)(T bar){...} byte bar = 9; foo!byte(bar + 1); //Error: function foo!byte.foo (byte bar) is not callable using argument types

Re: Create uninitialized dynamic array

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Thursday, 5 October 2017 at 21:04:30 UTC, Adam D. Ruppe wrote: On Thursday, 5 October 2017 at 19:59:48 UTC, Igor Shirkalin wrote: Is there a pure way to make what I want? oh i almost forgot about this function too: http://dpldocs.info/experimental-docs/std.array.uninitializedArray.1.html

Re: Create uninitialized dynamic array

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Thursday, 5 October 2017 at 20:19:15 UTC, Adam D. Ruppe wrote: On Thursday, 5 October 2017 at 19:59:48 UTC, Igor Shirkalin wrote: I want to quickly fill it with my own data and I do not want to waste CPU time to fill it with zeros (or some other value). You could always just allocate it

Re: Looking for a mentor in D

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 3 October 2017 at 06:54:01 UTC, eastanon wrote: I have been reading the D forums for a while and following on its amazing progress for a long time. Over time I have even written some basic D programs for myself, nothing major or earth shuttering. I have downloaded and read Ali's

Create uninitialized dynamic array

2017-10-05 Thread Igor Shirkalin via Digitalmars-d-learn
Hello! Preface: I need 1G array of ints (or anything else). Problem: I want to quickly fill it with my own data and I do not want to waste CPU time to fill it with zeros (or some other value). I do like this: void main() { int[] data; // key code: data.length = SOMETHING; //

Re: Remove instance from array

2017-08-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:30:08

Re: Foreign threads in D code.

2017-07-12 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 09:49:32 UTC, Guillaume Piolat wrote: On Tuesday, 11 July 2017 at 22:59:42 UTC, Igor Shirkalin wrote: [...] -- Biotronic Thanks for very useful information! Just one small note. If you don't know the foreign thread lifetime, it's cleaner to detach it from

Re: Foreign threads in D code.

2017-07-11 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 06:18:44 UTC, Biotronic wrote: On Monday, 10 July 2017 at 20:03:32 UTC, Igor Shirkalin wrote: [...] If DRuntime is not made aware of the thread's existence, the thread will not be stopped by the GC, and the GC might collect memory that the thread is referencing

Foreign threads in D code.

2017-07-10 Thread Igor Shirkalin via Digitalmars-d-learn
Hello! I have written some D code that I need to link to :C++ huge project. Let it be just one function that uses GC. The question is: if C++ code creates several threads and runs this :D function simultaneously, will GC work correctly? p.s. Of course the druntime is initialized before it.

Re: Remove instance from array

2017-07-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:30:08

Re: Remove instance from array

2017-07-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote: On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote: On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote: WhatEver[] q = []; [...] auto i = new WhatEver(); q[] = i; How does one remove that instance 'i'?

Re: Remove instance from array

2017-07-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote: WhatEver[] q = []; [...] auto i = new WhatEver(); q[] = i; How does one remove that instance 'i'? What exactly do you want to remove? After a[]=i your array contain a lot of references to 'i'.

Re: casting to structure

2017-06-24 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 24 June 2017 at 21:41:22 UTC, Moritz Maxeiner wrote: Hi, unfortunately not: - Operator overloading is supported via member functions only [1]. - Corollary: You cannot overload operators for builtin types (i.e. where the cast gets rewritten to `e.opOverloaded` where `e` is a

Re: casting to structure

2017-06-24 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 24 June 2017 at 20:43:48 UTC, Igor Shirkalin wrote: struct A { void * data; // void * type is just for example // no matter what is here } I know that if I add constructor this(int) struct A { void * p; this(int k) { p = cast(void*)k; } } auto a = cast(A)

casting to structure

2017-06-24 Thread Igor Shirkalin via Digitalmars-d-learn
Hello! I'm in trouble with opCast function. Is it possible to cast some (integral) type to user defined structure? We have a structure: struct A { void * data; // void * type is just for example // no matter what is here } How can we define opCast operator to make the following

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

2017-06-18 Thread Igor Shirkalin via Digitalmars-d-learn
On Sunday, 18 June 2017 at 16:02:38 UTC, Seb wrote: On Saturday, 17 June 2017 at 11:27:40 UTC, Igor Shirkalin wrote: On Saturday, 17 June 2017 at 11:23:52 UTC, Cym13 wrote: On Saturday, 17 June 2017 at 11:20:53 UTC, Igor Shirkalin wrote: [...] I'm sure others will have cleaner solutions as

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

2017-06-17 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 17 June 2017 at 11:23:52 UTC, Cym13 wrote: On Saturday, 17 June 2017 at 11:20:53 UTC, Igor Shirkalin wrote: [...] I'm sure others will have cleaner solutions as as a quick hack you can read the file at compile time, modify it, and compile the D code on the go: [...] Thanks

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

2017-06-17 Thread Igor Shirkalin via Digitalmars-d-learn
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 157 It comes from resource compiler and I need all these

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

2017-06-17 Thread Igor Shirkalin via Digitalmars-d-learn
Hello! I have a simple C header file that looks like: #define Name1 101 #define Name2 122 #define NameN 157 It comes from resource compiler and I need all these constants to be available in my Dlang program in compile time. It seems to me it is possible. I know I can simply write

Re: Strange expression found in std.variant

2017-06-03 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 3 June 2017 at 16:22:33 UTC, Francis Nixon wrote: When looking at std.variant I found the following line: return q{ static if (allowed!%1$s && T.allowed!%1$s) if (convertsTo!%1$s && other.convertsTo!%1$s) return VariantN(get!%1$s %2$s other.get!%1$s);

Re: Default class template parameter

2017-05-27 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 27 May 2017 at 19:30:40 UTC, Stanislav Blinov wrote: On Saturday, 27 May 2017 at 19:23:59 UTC, Igor Shirkalin wrote: [...] No, you'd have to at least write auto a = new ClassName!()(1.2); Or you could define a make function: auto makeClassName(T = double)(T value) { return

Default class template parameter

2017-05-27 Thread Igor Shirkalin via Digitalmars-d-learn
Hi, I try to make a class template with single template argument defaulted to some type. Is it possible to use the name of class without specification of template argumet (no '!' operator)? Example: class ClassName(T=double) { this(T value) { /// do some stuff here } /// some

Re: [Semi-OT] I don't want to leave this language!

2016-12-10 Thread Igor Shirkalin via Digitalmars-d-learn
On Monday, 5 December 2016 at 20:25:00 UTC, Ilya Yaroshenko wrote: Hi e-y-e, The main problem with D for production is its runtime. GC, DRuntime, Phobos is big constraint for real world software production. The almost only thing I do is real world software production (basically math and

Re: the best language I have ever met(?)

2016-12-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Monday, 5 December 2016 at 17:27:21 UTC, Igor Shirkalin wrote: On Monday, 5 December 2016 at 16:39:33 UTC, eugene wrote: On Monday, 5 December 2016 at 16:07:41 UTC, Igor Shirkalin wrote: I didnt count, but its about ten thousend a year, i.e. nothing. if you earned nothing using D language

Re: the best language I have ever met(?)

2016-12-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Monday, 5 December 2016 at 16:39:33 UTC, eugene wrote: On Monday, 5 December 2016 at 16:07:41 UTC, Igor Shirkalin wrote: I didnt count, but its about ten thousend a year, i.e. nothing. if you earned nothing using D language why do you recommend it?))) People usually earn money using

Re: the best language I have ever met(?)

2016-12-05 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 3 December 2016 at 15:02:35 UTC, eugene wrote: On Friday, 18 November 2016 at 17:54:52 UTC, Igor Shirkalin wrote: That was preface. Now I have server written in D for C++ pretty ancient client. Most things are three times shorter in size and clear (@clear? suffix). All

Re: the best language I have ever met(?)

2016-12-02 Thread Igor Shirkalin via Digitalmars-d-learn
On Monday, 28 November 2016 at 16:15:23 UTC, Jonathan M Davis wrote: That's what pragma(inline, true) is for. And if someone wants a different solution that's completely compile-time and doesn't work with variables, then fine. I'm talking about adding something to the standard library, and for

Re: the best language I have ever met(?)

2016-11-25 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 25 November 2016 at 07:17:18 UTC, MGW wrote: On Wednesday, 23 November 2016 at 18:54:35 UTC, Igor Shirkalin wrote: Igor, is the good Russian-speaking forum https://vk.com/vk_dlang. There are articles on GUI and other aspects of dlang. Thank you, I'll tale a look at it for sure.

Re: the best language I have ever met(?)

2016-11-25 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 25 November 2016 at 14:51:52 UTC, Jonathan M Davis wrote: I think you may write it (I mean actual D) with using some template like this: auto array = static_array!uint(1, 2, 3, 4) Could you please help to write down this template in the best and clear manner? That's easy. The

Re: the best language I have ever met(?)

2016-11-25 Thread Igor Shirkalin via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 18:58:55 UTC, ketmar wrote: We can define static array without counting the elements as following: enum array_ = [1u,2,3,4]; uint[array_.length] static_array = array_; there are workarounds, of course. yet i'll take mine `uint[$] a = [1u,2,3,4];` over that

Re: the best language I have ever met(?)

2016-11-23 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 00:08:05 UTC, ketmar wrote: On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote: Though I would argue that it's better to use '_' instead of '$' to denote deduced fixed size, it seems more obvious to me: int[_] array = [ 1, 2, 3 ]; alas, `_` is valid

Re: the best language I have ever met(?)

2016-11-19 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 20:54:32 UTC, ketmar wrote: On Saturday, 19 November 2016 at 17:12:13 UTC, Igor Shirkalin wrote: string s = "%(%s, %)".format(a); writefln(s); } Accepted. Is it really needed to call 'writefln'? I mean 'f'. no. it's a leftover from the code without

Re: the best language I have ever met(?)

2016-11-19 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote: import std.stdio; import std.format; void main () { uint[$] a = [42, 69]; string s = "%(%s, %)".format(a); writefln(s); } Please don't post non-d. People might use it an then complain that it does not work. Let these

Re: the best language I have ever met(?)

2016-11-19 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote: On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote: After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function

Re: the best language I have ever met(?)

2016-11-18 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 19:47:17 UTC, H. S. Teoh wrote: On Fri, Nov 18, 2016 at 11:43:49AM -0800, H. S. Teoh via Digitalmars-d-learn wrote: [...] Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) [...] Sorry, typo. I meant сентиментальности. But I think you

Re: the best language I have ever met(?)

2016-11-18 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 19:47:17 UTC, H. S. Teoh wrote: Yes, I meant 'sentiments' as in опыта, not as in сентметальность. :-) [...] Sorry, typo. I meant сентиментальности. But I think you understand what I mean. :-) Oh, I think you understand what you think what I mean :)

Re: the best language I have ever met(?)

2016-11-18 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 19:43:49 UTC, H. S. Teoh wrote: I was a little bit afraid of my missunderstanding in terms of sentiments. You've got me right (I don't quite feel the meaning of that in these non-cyrillic letters:). But what I understand is the path you have walked and what I

Re: the best language I have ever met(?)

2016-11-18 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 19:43:49 UTC, H. S. Teoh wrote: I was a little bit afraid of my missunderstanding in terms of sentiments. You've got me right (I don't quite feel the meaning of that in these non-cyrillic letters:). But what I understand is the path you have walked and what I

Re: the best language I have ever met(?)

2016-11-18 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 18:14:41 UTC, H. S. Teoh wrote: Welcome, Igor! Hello, Teoh! Your sentiments reflect mine years ago when I first discovered D. I came from a C/C++/Perl background. It was also Andrei's book that got me started; in those early days documentation was scant and

the best language I have ever met(?)

2016-11-18 Thread Igor Shirkalin via Digitalmars-d-learn
The simpler - the better. After reading "D p.l." by A.Alexandrescu two years ago I have found my past dream. It's theory to start with. That book should be read at least two times especially if you have asm/c/c++/python3/math/physics background, and dealt with Watcom/Symantec C/C++ compilers