Re: what's the correct way to handle unicode? - trying to print out graphemes here.

2018-07-04 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 3 July 2018 at 14:39:34 UTC, ag0aep6g wrote: Looks like forum.dlang.org has a problem when they appear side by-side. Works (in the preview): ‍‍‍ ️‍ Doesn't work: ‍‍‍️‍ For me, it looks as the used font has ligatures for these faces. Mozilla under Linux, I guess it's

Re: High memory usage in vibe.d application

2018-07-01 Thread crimaniak via Digitalmars-d-learn
On Sunday, 1 July 2018 at 13:44:23 UTC, Anton Fediushin wrote: I reduced the test case to _one_ line: ``` 1.seconds.setTimer(() => "http://google.com".requestHTTP((scope req) {}, (scope res) {res.disconnect;}), true); ``` What happens is `res.disconnect` doesn't free all of the internal

Re: Can't start application on heroku

2018-06-16 Thread crimaniak via Digitalmars-d-learn
On Saturday, 16 June 2018 at 09:00:21 UTC, Jacob Shtokolov wrote: 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

Can't start application on heroku

2018-06-15 Thread crimaniak via Digitalmars-d-learn
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 application. On the local machine, the application works as expected.

Re: How to task pool in vibe.d?

2018-06-09 Thread crimaniak via Digitalmars-d-learn
On Saturday, 9 June 2018 at 15:11:02 UTC, Computermatronic wrote: I'd like to create a bunch of tasks in vibe.d, then wait for them all to complete. Using std.concurrency and std.parallelism this is trivial. I could just spawn a bunch of vibe.d tasks and then iteratively join them, but I

Re: GDC on Travis-CI

2018-06-02 Thread crimaniak via Digitalmars-d-learn
On Saturday, 2 June 2018 at 19:48:36 UTC, Matthias Klumpp wrote: @crimaniak: If you really want to build with all compilers, there is a workaround for this issue that does not involve you supporting ancient D versions, and that is to actually use Debian's GDC on Travis. I use this

GDC on Travis-CI

2018-06-01 Thread crimaniak via Digitalmars-d-learn
I started to work with Travis-CI, building packages using all three main compilers, and noticed that I have problems with gdc every time and need to tweak code because of many things missing. For example: https://travis-ci.org/crimaniak/json-patch/jobs/386963340 Why this situation with gdc

Re: Any way to override base type with dervived in derived type

2018-05-25 Thread crimaniak via Digitalmars-d-learn
On Thursday, 24 May 2018 at 20:24:32 UTC, IntegratedDimensions wrote: I'm pretty much guaranteed that in C, t will be type TT due to the design(C goes with TT like bread with butter). ... 1) Your architecture is wrong, I recommend to rethink it. 2) You still can deal with it using template

Re: Reactive data

2018-04-02 Thread crimaniak via Digitalmars-d-learn
On Saturday, 31 March 2018 at 16:08:36 UTC, lempiji wrote: --- import rx; auto firstWord = new BehaviorSubject!string("Change"); auto secondWord = new BehaviorSubject!string("me!"); auto bothWords = new BehaviorSubject!string(""); combineLatest!((a, b) => a ~ " " ~ b)(firstWord,

Reactive data

2018-03-23 Thread crimaniak via Digitalmars-d-learn
I want to have reactive variables like in this example: ``` USING_REACTIVE_DOMAIN(D) // The two words VarSignalT firstWord = MakeVar(string( "Change" )); VarSignalT secondWord = MakeVar(string( "me!" )); // ... SignalT bothWords = firstWord + string( " " ) + secondWord; ``` from this page:

Re: Forwarding arguments through a std.algorithm.map

2018-03-10 Thread crimaniak via Digitalmars-d-learn
On Saturday, 10 March 2018 at 20:48:06 UTC, Nordlöw wrote: If I have a function bool f(Rs...)(Rs rs) is it somehow possible to map and forward all its arguments `rs` to another function bool g(Rs...)(Rs rs); docs: https://dlang.org/phobos/std_traits.html#.Parameters usage

Re: What's the proper way to add a local file dependence to dub?

2018-03-09 Thread crimaniak via Digitalmars-d-learn
On Sunday, 4 March 2018 at 16:46:56 UTC, Marc wrote: then copy it to sources folder? ... Also, symlinks are power tool for organizing your files without copying.

Re: need help with vibe.d receive()

2018-01-16 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 16 January 2018 at 08:54:58 UTC, Sönke Ludwig wrote: ... The problem is with the `immutable struct StopEvent {}` Thanks! ... So, removing the `immutable` from the declaration solved the issue for me, but if possible I'd rather remove the `cast(shared Unqual!EventType)` from

need help with vibe.d receive()

2018-01-10 Thread crimaniak via Digitalmars-d-learn
Hi! I make multi-task event bus, but there is a problem with the task stops. Please see end of file https://github.com/crimaniak/d-vision/blob/master/src/vision/eventbus.d Expected behavior: After sending the StopEvent message in line 244 it is must be detected in listeners (line 147), so

Re: why ushort alias casted to int?

2017-12-22 Thread crimaniak via Digitalmars-d-learn
On Friday, 22 December 2017 at 10:18:52 UTC, ketmar wrote: crimaniak wrote: Both operands are the same type, so as I understand casting to longest type is not needed at all, and longest type here is ushort in any case. What am I doing wrong? it is hidden in specs: all types shorter than int

why ushort alias casted to int?

2017-12-22 Thread crimaniak via Digitalmars-d-learn
My code: alias MemSize = ushort; struct MemRegion { MemSize start; MemSize length; @property MemSize end() const { return start+length; } } Error: cannot implicitly convert expression `cast(int)this.start + cast(int)this.length` of type `int` to `ushort` Both

Re: git workflow for D

2017-12-04 Thread crimaniak via Digitalmars-d-learn
On Sunday, 3 December 2017 at 20:05:47 UTC, bitwise wrote: How does one keep their fork up to date? For example, if I fork https://help.github.com/articles/syncing-a-fork/

Re: Basic questions about D lang?

2017-11-29 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 11:32:51 UTC, Jayam wrote: In D lang, 1. Is there any feature async/ await like "c#" ? I can't find feature like async. As for me, async/await feature is a half-baked solution. With vibe-d you can write asynchronous code without thinking about it at all.

Problems with ctRegex

2017-11-28 Thread crimaniak via Digitalmars-d-learn
First problem: it doesn't understand enums, it seems to be a bug: ``` enum TopicMask : string { divider = "/", oneLevelMask = "+", multiLevelMask = "#", system = "$", level = "[^"~divider~oneLevelMask~multiLevelMask~"]*", publishMask =

Re: Is variable void?

2017-11-26 Thread crimaniak via Digitalmars-d-learn
On Saturday, 25 November 2017 at 15:34:21 UTC, John Chapman wrote: Is there any way of determining whether a variable has been initialized or not? For example, if something is declared like this: int x = void; can I check if it's void before I use it, say, in a function it's been passed

deep copy thread local to shared or how to send() struct with indirections

2017-11-23 Thread crimaniak via Digitalmars-d-learn
Hi! I need to send Publish struct from https://github.com/tchaloupka/vibe-mqtt to another vibe.d task. And there is the problem. First of all, I can't make it immutable because send() wants to mutate it. I can't send local copy because of "Aliases to mutable thread-local data not allowed.".

Re: Synchronize Class fields between different threads

2017-11-10 Thread crimaniak via Digitalmars-d-learn
On Friday, 10 November 2017 at 14:36:03 UTC, DrCataclysm wrote: It is working now. The problem was that the debugger in eclipse ddt seems to completely broken. If i run it directly from bash it is working. Be careful with such statements. Typically, this situation means that there are

Re: How to use containers in lock based concurrency

2017-11-03 Thread crimaniak via Digitalmars-d-learn
On Friday, 3 November 2017 at 12:42:29 UTC, ANtlord wrote: Hello! I can't get how to use double linked list in concurrency. Please help. ... I get a compile error onlineapp.d(8): Error: template std.container.dlist.DList!string.DList.insertFront cannot deduce function from argument types

Re: Tango + D2 + Mac

2017-10-17 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 04:01:54 UTC, Fat_Umpalumpa wrote: Do you by any chance know anything that replaced std.xml? Everything I look up on it suggests not to use it. Is this really a problem? In this case, I can help: I recommend to use it. And only if you really will have

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: Returning multiple values from a function

2017-09-04 Thread crimaniak via Digitalmars-d-learn
On Monday, 4 September 2017 at 09:22:25 UTC, Vino.B wrote: Thank you very much, i have used your idea and was able to resolve, and i need one more favor. the below code outputs the value but i need the name of the variable + value as below. Output : 1 2 ["C:\\Temp\\TEAM1\\BACKUP",

Re: Bug in D!!!

2017-09-04 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 20:47:12 UTC, EntangledQuanta wrote: interface I { void Go(T)(S!T s); static final I New() { return new C(); } } abstract class A : I { } class C : A { void Go(T)(S!T s) {

Re: Returning multiple values from a function

2017-09-04 Thread crimaniak via Digitalmars-d-learn
On Monday, 4 September 2017 at 07:27:12 UTC, Vino.B wrote: Hi, Can you help me in how to return multiple values from a function, the below code is throwing an error as below import std.stdio: writeln; import std.typecons: tuple, Tuple; Tuple!(int, string[]) Params () { return tuple(1,

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-20 Thread crimaniak via Digitalmars-d-learn
On Monday, 21 August 2017 at 02:17:57 UTC, crimaniak wrote: ... shared A a; ... Sorry, accidental delete, read this as shared A a = new shared(A);

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-20 Thread crimaniak via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:59:48 UTC, Jonathan M Davis wrote: And no, this isn't ideal, but the only semi-decent solution that's been proposed that safely casts away shared for you is synchronized classes, which Andrei describes in TDPL but have never been implemented. After reading

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-20 Thread crimaniak via Digitalmars-d-learn
On Thursday, 17 August 2017 at 13:09:29 UTC, Kagamin wrote: On Wednesday, 16 August 2017 at 23:15:10 UTC, crimaniak wrote: I wonder if it possible and usable to make some template to support this pattern, where we give mutex(es), shared object(s) and delegate to operate with objects as

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-16 Thread crimaniak via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:59:48 UTC, Jonathan M Davis wrote: The way to handle shared is to protect the section of code that's using the shared object with either a mutex or synchronized block, and then you cast away shared from the object within that section and operate on it as

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-13 Thread crimaniak via Digitalmars-d-learn
On Sunday, 13 August 2017 at 11:35:05 UTC, Arek wrote: Yeah, I've read this. But conurrency.send cannot pass immutable object. The same story with Unique. Sorry, read this as 'efficient immutable'. More over, "shared" looks rather like unfinished concept. Yes, exactly. Anyway, _gshared

Re: Does anyone understand how to use "shared" types with concurrency send/receive functions?

2017-08-12 Thread crimaniak via Digitalmars-d-learn
On Saturday, 12 August 2017 at 18:57:44 UTC, Arek wrote: I have the folowing problem: I like to envelope the class object in struct to control the destruction moment and then send this object to another thread/fiber (or task, cause I use vibe-d). I can't find any method to make it working.

Re: stacktrace for InvalidMemoryOperationError

2017-07-16 Thread crimaniak via Digitalmars-d-learn
On Saturday, 15 July 2017 at 18:14:13 UTC, Joakim wrote: core.exception.InvalidMemoryOperationError@src/core/exception.d(696): Invalid memory operation ... See the wiki page about this: https://wiki.dlang.org/InvalidMemoryOperationError If you can't do all that, look for places you might be

Re: char e string em linguagem D

2017-07-14 Thread crimaniak via Digitalmars-d-learn
On Thursday, 13 July 2017 at 22:36:47 UTC, Basile B. wrote: return cast(char[])` ... Never cast a literal to char[]. modifying the resulting char[] will lead to AV, at least under linux. `.dup` the literal if you really needs char[]. Hmm, yes, my bad. Probably, it was necessary even

Re: char e string em linguagem D

2017-07-13 Thread crimaniak via Digitalmars-d-learn
On Thursday, 13 July 2017 at 21:49:40 UTC, dark777 wrote: Pessoal eu fiz o seguinte programa em C++. https://pastebin.com/CvVv6Spn porem tentei fazer o equivalente em D mas nao entendi muito bem... https://pastebin.com/2xw9geRR alguem poderia me ajudar? Se acepta utilizar intervalos en

Re: Having a strange issue with std.net.curl.HTTP as a struct dependency

2017-07-12 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 13:47:06 UTC, Adam D. Ruppe wrote: This tells me the problem is in the collection order at the end of the program. ... So I'd say the answer is prolly to keep HTTP away from the GC. Manually free its arrays, or keep them outside arrays in the first place. I'd

Re: mysql-native ResultRange + map

2017-07-11 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 11 July 2017 at 22:46:00 UTC, Steven Schveighoffer wrote: On 7/5/17 12:04 PM, crimaniak wrote: ... Because of the temporary copy likely inside map closes the connection. See the bug I reported: https://github.com/mysql-d/mysql-native/issues/117 Yes, it seems to be the same

stacktrace for InvalidMemoryOperationError

2017-07-10 Thread crimaniak via Digitalmars-d-learn
Hi! I have vibe.d application and long-standing error in it. For the current moment, I have logs for stdout, stderr, and additional log to write exceptions I catch. This error gives me only the short line in stderr log: core.exception.InvalidMemoryOperationError@src/core/exception.d(696):

mysql-native ResultRange + map

2017-07-05 Thread crimaniak via Digitalmars-d-learn
Hi all! After some hard time with debugging, I found ResultRange returned by query() and Prepared::query() of mysql-native package can't be combined with map() because after map() it becomes empty resultset. Code (conn.queryRows just a wrapper for query(Connections, sql) ):

Re: weird error message

2017-07-05 Thread crimaniak via Digitalmars-d-learn
On Sunday, 2 July 2017 at 01:06:29 UTC, Ali Çehreli wrote: On 07/01/2017 04:56 PM, crimaniak wrote: > about very long error messages generated in some > cases. Please submit a bug report. The compiler may be able to abbreviate certain types. For example, in this case most of the error

Re: weird error message

2017-07-01 Thread crimaniak via Digitalmars-d-learn
On Saturday, 1 July 2017 at 22:46:06 UTC, Adam D. Ruppe wrote: On Saturday, 1 July 2017 at 22:44:33 UTC, crimaniak wrote: enum moduleMask = ctRegex!`module\s+([^;]+)`; That should be `static`, not `enum`. I betcha that will at least change the error. Works both variants, and reason

weird error message

2017-07-01 Thread crimaniak via Digitalmars-d-learn
Just for fun (may be): code: auto findModule = execute(["dscanner", "--etags", entry.name]); enum moduleMask = ctRegex!`module\s+([^;]+)`; Captures c = findModule.output.matchFirst!(moduleMask); result (even C++ guys will be impressed): phobos_imports.d(43): Error:

Re: mysql-native + vibe.d example

2017-06-30 Thread crimaniak via Digitalmars-d-learn
On Friday, 30 June 2017 at 16:18:33 UTC, tetyys wrote: On Friday, 30 June 2017 at 00:52:28 UTC, crimaniak wrote: Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: seems like it's already fixed

mysql-native + vibe.d example

2017-06-29 Thread crimaniak via Digitalmars-d-learn
Hi! Moving my project from mysql-lited to mysql-native I faced the problem with null pointer error inside of mysql-native: Log: SELECT id FROM versionupdate ORDER BY id Task terminated with unhandled exception: etc.linux.memoryerror.NullPointerError@src/etc/linux/memoryerror.d(325)

site examples

2017-05-25 Thread crimaniak via Digitalmars-d-learn
I tried to run an example from the site. Example from https://dlang.org/phobos/std_regex.html#replaceAllInto section. And this is problem number 0: I can't give a link to the example, only to section. The section can be long, there can be more than one example, so it's good to have an anchor

Re: Code improvement for DNA reverse complement?

2017-05-19 Thread crimaniak via Digitalmars-d-learn
On Friday, 19 May 2017 at 12:55:05 UTC, Biotronic wrote: revComp6 seems to be the fastest, but it's probably also the least readable (a common trade-off). Try revComp7 with -release :) string revComp7(string bps) { char[] result = new char[bps.length]; auto p1 = result.ptr; auto p2

Re: How to write parser?

2017-05-15 Thread crimaniak via Digitalmars-d-learn
On Sunday, 14 May 2017 at 19:00:09 UTC, Suliman wrote: I am trying to learn how to write text parser. I have example doc with follow format: #Header my header text ##SubHeader my sub header text it's there any better way to parse such format? Ready markdown Pegged based parser:

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-11 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote: I have a line of code that uses "to" function in std.conv for a purpose like: int index = to!int( user_apply[ 4 ] ); // string to int When the user_apply[ 4 ] has value, there is no problem; but when it is empty: "" it throws an

Re: Productive vibe.d dev environment (IDE, debugger) on Linux?

2017-05-08 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 3 May 2017 at 17:43:07 UTC, kinke wrote: can anyone recommend a more or less production-ready dev environment for vibe.d on Linux? I'm evaluating vibe.d against Phoenix (Elixir/Erlang) for a new project. Today I gave Visual Studio Code a quick shot (with LDC 1.1.1 and DMD

Re: The app hanging after reach 1750MB of RAM

2017-04-19 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 18 April 2017 at 11:43:24 UTC, Suliman wrote: I am writing app that extract data from DB to array of structures. void getSingleTrackInfo() { foreach(item; getTablesGPSSensorList) { ResultRange

URL (or URI) Pegged grammar - is it exists?

2017-04-10 Thread crimaniak via Digitalmars-d-learn
Hi, all! Yes, I know, most simple way to validate URL is regex and it works for most cases, but I search for a correct solution (ideally rfc3986-compatible), which will be hard to implement using regular expressions.

Re: 'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread crimaniak via Digitalmars-d-learn
On Saturday, 25 March 2017 at 16:08:49 UTC, NotSpooky wrote: __gshared implies static,... Thanks! Confusing for me moment.

'fopen64 cannot be interpreted at compile time' for __gshared File

2017-03-25 Thread crimaniak via Digitalmars-d-learn
Simple File test: void main() { import std.stdio; File f = File("test.txt", "w"); f.writeln("hello"); } All works as expected. Now let's add __gshared: void main() { import std.stdio; __gshared File f = File("test.txt", "w");

Re: how to test if member of instance exists/defined?

2017-03-22 Thread crimaniak via Digitalmars-d-learn
On Wednesday, 22 March 2017 at 20:35:27 UTC, StarGrazer wrote: I've tried compiles but I guess that only checks if the code has valid syntax, not if it actually will compile in context. https://dlang.org/spec/traits.html#hasMember

Re: Question about vibe.conf file

2017-03-05 Thread crimaniak via Digitalmars-d-learn
On Sunday, 5 March 2017 at 13:41:23 UTC, Suliman wrote: I had seen some mentions about `vibe.conf` file in vibed docs. But can't understand it's structure and find examples of it's usage. Json file. Real example: ``` { "mqttHost" : "***.***.**.***", "mqttPort" :

Problem with send / receive

2017-03-03 Thread crimaniak via Digitalmars-d-learn
Hi all! I make vibe-d based project and now I have problem passing messages between threads. First some words about architecture. Each event in the system has a corresponding class that validates and performs the required actions. Each class has a nested structure with the parameters that

Re: code D'ish enough? - ignore previous post with same subject

2017-02-28 Thread crimaniak via Digitalmars-d-learn
On Sunday, 26 February 2017 at 21:50:38 UTC, Jordan Wilson wrote: .map!(a => a.to!double) If lambda just calls another function you can pass it directly: == .map!(to!double)

Re: Getting a segfault here, why?

2017-02-16 Thread crimaniak via Digitalmars-d-learn
On Thursday, 16 February 2017 at 09:18:16 UTC, aberba wrote: On linux it is pretty easy. Just compile with `-g` to dmd and run the program in gdb. Run till it crashes and it should tell you the file and line of where. Thanks, will try and see. Also don't forget to do this:

Re: Iterate module membres

2017-01-07 Thread crimaniak via Digitalmars-d-learn
Ok, I found it: https://issues.dlang.org/show_bug.cgi?id=16044

Re: Iterate module membres

2017-01-07 Thread crimaniak via Digitalmars-d-learn
On Saturday, 7 January 2017 at 12:29:34 UTC, ketmar wrote: On Saturday, 7 January 2017 at 12:11:20 UTC, crimaniak wrote: Is this a bug or documentation problem? well, it's hard to say. package.d is one of the cases where you *have* to provide explicit module definition. ;-) 'cause implicit

Re: Iterate module membres

2017-01-07 Thread crimaniak via Digitalmars-d-learn
On Saturday, 7 January 2017 at 10:38:29 UTC, ketmar wrote: On Saturday, 7 January 2017 at 10:27:51 UTC, Nicholas Wilson wrote: Do you require a module statement per chance? it doesn't matter. if there is no explicit module declaration, compiler will insert implicit one. from the code PoV,

Iterate module membres

2017-01-07 Thread crimaniak via Digitalmars-d-learn
Hi! I need to iterate module members and find specific classes (and make tuple). class foo{}; pragma (msg, __traits(allMembers,mixin(__MODULE__))); gives me empty tuple. I found also this thread from 2011:

Re: [question] Access from UDA constructor to parent symbol

2016-12-27 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 27 December 2016 at 02:05:27 UTC, Ali Çehreli wrote: On 12/26/2016 02:04 PM, crimaniak wrote: So my main question: how it is possible to do such thing? Just to make sure we're on the same page: :) * There is 'interface' in addition to 'class' Yes. I want it for structs

Re: [question] Access from UDA constructor to parent symbol

2016-12-26 Thread crimaniak via Digitalmars-d-learn
On Monday, 26 December 2016 at 21:15:03 UTC, Adam D. Ruppe wrote: On Monday, 26 December 2016 at 20:07:56 UTC, crimaniak wrote: // I want to see Foo here and use it's reflection to iterate fields and methods. then pass foo to it What do you mean parent symbol? I assumed you mean

[question] Access from UDA constructor to parent symbol

2016-12-26 Thread crimaniak via Digitalmars-d-learn
``` class uda { this() { // I want to see Foo here and use it's reflection to iterate fields and methods. } } @uda struct Foo { } ``` Is there a way to do it?

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread crimaniak via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have

rpc between Tasks of vibe.d

2016-10-28 Thread crimaniak via Digitalmars-d-learn
Hi All! I will try to illustrate by code what exactly I have in mind: // we have not shared class/struct with some interface. class FooController { ... int foo1(int a, string b); string foo2(Struct1 c); ... } // now we want to make a running task with an instance inside auto

Re: thisExePath purity

2016-09-20 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 13:35:27 UTC, Steven Schveighoffer wrote: Yes, but if your code does instantiate it, it is called, even if you don't ever call the function that calls it. Yes, it's not ideal but better then just global variable and static block - it's called in any case, even

Re: thisExePath purity

2016-09-20 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 09:14:39 UTC, Marc Schütz wrote: Have a look at `std.concurrency.initOnce`: https://dlang.org/phobos/std_concurrency.html#.initOnce But you will still need to use assumePure() for calling `thisExePath`, and it might do other things that are impure... Yes,

Re: thisExePath purity

2016-09-20 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 04:26:05 UTC, Jonathan M Davis wrote: On Tuesday, September 20, 2016 04:17:21 crimaniak via Digitalmars-d-learn wrote: static shared immutable ReturnType!T value; I would point out that immutable is implicitly shared, so there's no reason to put

Re: thisExePath purity

2016-09-19 Thread crimaniak via Digitalmars-d-learn
Hi and thanks all! On Tuesday, 20 September 2016 at 00:43:10 UTC, Jonathan M Davis wrote: immutable string executablePath; shared static this() { import std.file : thisExePath(); executablePath = thisExePath(); } This code is good for my needs but I start to think about how to

thisExePath purity

2016-09-19 Thread crimaniak via Digitalmars-d-learn
Hi! Is there situations when output of thisExePath() can be different during runtime? If yes, what the reason? If no, is this possible to mark it as pure in phobos? https://dlang.org/library/std/file/this_exe_path.html

Compiling vibe.d application for Amazon ec2 instance

2016-09-11 Thread crimaniak via Digitalmars-d-learn
Hi all! I made vibe-d application, and client give me already taken hosting for it on Amazon aws ec2, uname -a: Linux ip-xxx-xx-xx-xx 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux Compiled on my Ubuntu binary don't run because of different

Re: Can anybody install DDT on Eclipse Neon or Mars?

2016-06-19 Thread crimaniak via Digitalmars-d-learn
On Saturday, 18 June 2016 at 16:46:26 UTC, Mark wrote: I've spent may hours trying to do this in OSX. Everything goes fine from the marketplace window...until I restart Eclipse and find no files have been added? Any words of consolation or advice will be greatly appreciated. I have Eclipse

Re: Missing Symbol Accessing Templated Function Through Interface

2016-03-08 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 8 March 2016 at 11:50:32 UTC, Peter wrote: Hi, Can anyone explain to me what's causing the following code to generate a missing symbol error... Relevant comment: https://issues.dlang.org/show_bug.cgi?id=8553#c1

Re: Does D optimize sqrt(2.0)?

2016-02-11 Thread crimaniak via Digitalmars-d-learn
On Thursday, 11 February 2016 at 07:41:55 UTC, Enjoys Math wrote: If I just type out sqrt(2.0) in D, is that automatically made into a constant for me? Thanks. for DMD -O : import std.math; immutable foo = sqrt(2.0); pure float precalculated() { return foo; } pure float

How to implement to!T(JSONValue)?

2016-01-31 Thread crimaniak via Digitalmars-d-learn
Hi! I need to read bad-formed json files in type-tolerant mode, and my idea is to make JSONValue-specific 'to' method which will convert it to target type if applicable, else throw exception. Like this: import std.json; unittest { JSONValue s="123"; JSONValue i=123; JSONValue

Re: Balanced match with std.regex

2015-12-14 Thread crimaniak via Digitalmars-d-learn
On Tuesday, 15 December 2015 at 00:16:41 UTC, Jakob Ovrum wrote: Is there a way to do balanced match with std.regex? It's only possible with (?R) implemented: http://php.net/manual/en/regexp.reference.recursive.php But there is no (?R) in D regex implementation.

Re: method has no return statement with switch

2015-11-07 Thread crimaniak via Digitalmars-d-learn
On Saturday, 7 November 2015 at 06:02:49 UTC, BBaz wrote: On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: [...] url.Cache.UrlCache.doRequest has no return statement, but is expected to return a value of type string [...] public string doRealRequest(string url, Method

method has no return statement with switch

2015-11-06 Thread crimaniak via Digitalmars-d-learn
Hi! I have the error message: source/url.cache.d(20,16): Error: function url.Cache.UrlCache.doRequest has no return statement, but is expected to return a value of type string Inserting dummy return statement doesn't help. final switch / switch with default - no matter. As I understand

Re: method has no return statement with switch

2015-11-06 Thread crimaniak via Digitalmars-d-learn
On Saturday, 7 November 2015 at 00:27:02 UTC, Adam D. Ruppe wrote: On Saturday, 7 November 2015 at 00:21:57 UTC, crimaniak wrote: Inserting dummy return statement doesn't help. final switch / switch with default - no matter. Try inserting assert(0); instead of a dummy return. Done, no