Re: How to store a pointer to class contructor

2020-12-24 Thread Jacob Shtokolov via Digitalmars-d-learn
On Thursday, 24 December 2020 at 10:23:09 UTC, Dmitriy Asondo wrote: Hi! I'm trying to check some js-like features. For example, if I want to store somewhere in array|tuple a list of pointers to classes (app services) how may I do that? Hi, it seems that what you're looking for is Prototype

Re: Small program producing binary with large filesize

2019-11-10 Thread Jacob Shtokolov via Digitalmars-d-learn
On Monday, 21 October 2019 at 19:20:04 UTC, Prokop Hapala wrote: What exactly should I specify to make it link dynamcially and produce as small binary as possible (without increasing compilation time) ? Hi! Sorry, just found your response here. In order to force it to link dynamically, add

Distinguish float and integer types from string

2019-03-09 Thread Jacob Shtokolov via Digitalmars-d-learn
Hi, Recently, I was trying to solve some funny coding challenges (https://www.techgig.com). The questions were really simple, but I found it interesting because the website allows to use D. One of the task was to take a string from STDIN and detect its type. There were a few options: Float,

Re: opEquals() non-standard return type

2019-01-24 Thread Jacob Shtokolov via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 17:28:37 UTC, H. S. Teoh wrote: The best way to do this is to use a string DSL or a delegate as template argument. For example: auto result = User.filter!q{ User.name == "John" }; or: auto result = User.filter!(u => u.name == "John"); I

Re: opEquals() non-standard return type

2019-01-24 Thread Jacob Shtokolov via Digitalmars-d-learn
On Thursday, 24 January 2019 at 00:47:37 UTC, Ali Çehreli wrote: Yeah, that can't work. Remove the bool-returning one and your code works with the 'alias this' above. Wow, this is an amazing workaround! I didn't think about it in that way. It perfectly solves the issue. Thank you!

Re: opEquals() non-standard return type

2019-01-23 Thread Jacob Shtokolov via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 15:28:02 UTC, Jonathan M Davis wrote: But regardless of the specifics of operator overloading in D, D does not support overloading _any_ functions on the return type. Thanks!

opEquals() non-standard return type

2019-01-23 Thread Jacob Shtokolov via Digitalmars-d-learn
Hi, I'm trying to check whether it's possible to implement Python's SQLAlchemy-like query syntax in D, but I get stuck a bit. Here is a simple example of what I want to achieve: ``` auto result = User.filter(User.id == 10); result = User.filter(User.name == "John"); result =

Re: Compile time opAssign/@property constraints

2019-01-05 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 14:36:16 UTC, Mike Parker wrote: v is a run-time value, not available at compile time. Sorry about that, looks like if I edit the text in the run.dlang.io editor, the link also gets updated. I was using "void opAssign(T)(T v)" in the initial example, but it seems

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:45:24 UTC, Jacob Shtokolov wrote: Here is the simple example: https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6 Sorry, invalid link. Here is a new one: https://run.dlang.io/is/QZ5hLV

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 11:41:59 UTC, Simen Kjærås wrote: The thing is, compile-time tests like static if and static assert can only test values that are known at compile-time, and are for the most part useful only in templates. Thanks for this answer! That's sad to hear. But, is there

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 4 January 2019 at 10:34:07 UTC, Basile.B wrote: Show us some code. Here is the simple example: https://run.dlang.io/gist/1a06dd703bea5548ee72b4713a7ce5f6 The thing I'm trying to do is to make an experimental port (for education purposes) of https://github.com/fthomas/refined

Compile time opAssign/@property constraints

2019-01-04 Thread Jacob Shtokolov via Digitalmars-d-learn
Hi, I'd like to implement some compile time constraints for a struct (though not sure if that's possible). I already tried to place "static assert" or any kind of static condition into a body of @property and opAssign(), but every time it shows the error "variable cannot be read at compile

Re: How to understand context type of a delegate?

2018-09-08 Thread Jacob Shtokolov via Digitalmars-d-learn
On Wednesday, 5 September 2018 at 16:53:42 UTC, NX wrote: Is there a way to know what kind of context a delegate has either in compile time or runtime? Also is there any way to check whether a pointer legitimately points to an Object instance? No and no. I was fighting this problem in

Re: Is there a simple way to check if value is null for every case?

2018-08-27 Thread Jacob Shtokolov via Digitalmars-d-learn
On Monday, 27 August 2018 at 14:11:32 UTC, SG wrote: On Monday, 27 August 2018 at 13:02:28 UTC, rikki cattermole wrote: So Nullable in D and C# is basically the same except C#'s has language support. Shouldn't it be in the standard library? I think it's worth it to create a feature request

Re: Small program producing binary with large filesize

2018-08-01 Thread Jacob Shtokolov via Digitalmars-d-learn
On Tuesday, 31 July 2018 at 15:19:19 UTC, Dan Barbarito wrote: Hi all, I am starting to write a command line tool. Hi! First, Vibe.d will increase your binary size because it contains a lot of unnecessary things inside it. So instead of using the entire vibe.d library, you may point dub to

Re: Dlangui customize app icon on dock or menu bar

2018-07-25 Thread Jacob Shtokolov via Digitalmars-d-learn
On Wednesday, 25 July 2018 at 09:42:00 UTC, Ivo wrote: I'm a macOs user and I need to build a application with a GUI. Not sure if the author of the DLangUI is visiting this forum so often to be able to answer. If you won't get an answer in the next few days, I would recommend to make an

Re: High memory usage in vibe.d application

2018-07-01 Thread Jacob Shtokolov via Digitalmars-d-learn
On Sunday, 1 July 2018 at 05:20:17 UTC, Anton Fediushin wrote: Now I tried it and indeed, it's vibe.d's fault. I'm not quite sure what causes it and if this problem is known, I'll look into that later and open an issue if it doesn't exist already. Yes, please do this when you have time. That

Re: High memory usage in vibe.d application

2018-06-30 Thread Jacob Shtokolov via Digitalmars-d-learn
On Friday, 29 June 2018 at 17:40:07 UTC, Anton Fediushin wrote: So, long story short: - Usage of Mallocator instead of theAllocator made it a little bit better - VibeManualMemoryManagement had no (or little) effect - Manually calling GC.collect had no (or little) effect You could try to call

Re: Can't start application on heroku

2018-06-16 Thread Jacob Shtokolov via Digitalmars-d-learn
On Saturday, 16 June 2018 at 01:24:04 UTC, crimaniak wrote: Hi all! The first try to host application on Heroku provider. The application is started and starts to listen in 3 seconds on the port, provided by heroku-buildpack-d. But the server doesn't detect listening and stops the