Re: Are there any D scripting engines for use with D?

2016-01-04 Thread Max Klyga via Digitalmars-d-learn
On 2016-01-04 18:40:03 +, Jason Jeffory said: We have many scripting engines available for use in D more or less(lua, python, etc...). Is there a D scripting engine that can be easily integrated into a D project? A sort of "exec()". Something that works at compile time and run time possi

Re: Templates: Array slices not recognized

2015-04-18 Thread Max Klyga via Digitalmars-d-learn
On 2015-04-18 13:46:19 +, Chris said: The following: import std.stdio : writefln; import std.range.primitives : isInputRange, hasLength; void main() { size_t[] a = [1, 2, 3, 4, 5, 6, 7, 8, 9]; doSomething(a); // works doSomething(a[0..5]); // ---> Error: template slices.doSomet

Re: Interlocked (compare) exchange

2015-04-17 Thread Max Klyga via Digitalmars-d-learn
On 2015-04-17 10:36:31 +, Szymon Gatner said: Hi, are there equivalents of Interlocked.Exchange [1] and Interlocked.CompareExchange [2] in D? I can't find it in teh docs? [1] https://msdn.microsoft.com/en-us/library/f2090ex9(v=vs.110).aspx [2] https://msdn.microsoft.com/en-us/library/h7

Re: string-int[] array

2015-03-08 Thread Max Klyga via Digitalmars-d-learn
On 2015-03-08 21:11:42 +, Paul said: On Sunday, 8 March 2015 at 18:05:33 UTC, Dennis Ritchie wrote: Is it possible to create such an array in which you can store strings and numbers at the same time? string-int[] array = [4, "five"]; As there's no mention of performance, what's wrong wi

Re: Object as function argument

2015-03-05 Thread Max Klyga via Digitalmars-d-learn
On 2015-03-05 19:35:34 +, Chris Sperandio said: Hi, I'm a developer coming from C and I've a question about class instance as method or function parameter. In the book "The D Programming Language", I read the instance was passed by reference to functions (in the opposite of structures). I

Re: Insert if doesn't exist without double lookup.

2014-03-15 Thread Max Klyga
On 2014-03-15 18:44:46 +, Agustin said: Hello!, i would like to know if this is possible. auto asValue ?= (map["Key"] == new Value); Instead of doing: if (("Key" in map) is null) map["Key"] = new Value auto asValue = map["Key"]; auto needle = "Key" in map; auto value = needle ? *nee

Re: Binary Data Serialization Libraries

2013-12-06 Thread Max Klyga
On 2013-12-06 13:33:44 +, Jeroen Bollen said: Are there any Binary Data Serialization Libraries available written in D2? I'm looking for something like a BSON read/write library. (Although can be any other binary language really) MessagePack - format very similar to BSON - https://github

Re: Monads compared to InputRanges?

2013-12-04 Thread Max Klyga
On Wednesday, 4 December 2013 at 08:24:03 UTC, qznc wrote: On Wednesday, 4 December 2013 at 01:53:39 UTC, Shammah Chancellor wrote: Or is D syntax not generic enough to define monads? I started to port monads to D [0]. You can do it, but it looks ugly. The trick is to implement (Haskell) type

Re: Monads compared to InputRanges?

2013-12-04 Thread Max Klyga
On Wednesday, 4 December 2013 at 10:03:51 UTC, Timon Gehr wrote: On 12/04/2013 12:49 AM, Max Klyga wrote: range.map(...).flatten.map(...) might look similar and it could be possible to squeeze monads to work with this api, but the thing is that not every monad could provide a meaningful

Re: Monads compared to InputRanges?

2013-12-03 Thread Max Klyga
On 2013-12-04 01:53:39 +, Shammah Chancellor said: On 2013-12-03 23:49:47 +, Max Klyga said: On 2013-12-03 23:02:13 +, Shammah Chancellor said: On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly fam

Re: Monads compared to InputRanges?

2013-12-03 Thread Max Klyga
On 2013-12-03 23:02:13 +, Shammah Chancellor said: On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out h

Re: Monads compared to InputRanges?

2013-12-03 Thread Max Klyga
On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out how this is different from UFCS on InputRanges. It seems like std.algorithm implements something which accomplished the

Re: Optional equivalent in D?

2013-11-16 Thread Max Klyga
On 2013-11-16 05:04:20 +, Jonathan M Davis said: I really don't understand this. Optional is one of the most useless ideas that I've ever seen in Java. Just use null. Optional specifies explicitly that value can be absent and forces client to check before using the value. Also, if Optiona

Re: Embed JavaScript into D

2013-11-04 Thread Max Klyga
On 2013-11-04 21:20:46 +, Adam D. Ruppe said: On Monday, 4 November 2013 at 19:35:55 UTC, Jeroen Bollen wrote: Is there a way I can embed javascript into my D application? You could use any C javascript lib too, but for ones already wrapped or something, I know there's a few D implementa

Re: for loop

2012-01-22 Thread Max Klyga
On 2012-01-22 16:23:36 +0300, RenatoL said: This works: import std.stdio; void main() { int x = 0; int y = 0; for(; ((x < 5) && (y < 5)); x++, y ++) { writeln("x + y = ", x + y); } } The question is easy: is it possible to insert x and y internally in the for header

Re: multiple return

2011-04-19 Thread Max Klyga
On 2011-04-20 01:35:46 +0300, %u said: I have function which have more than one return, and the code compile and run but it gives rong result -I guess-, so i use tuple but the compiler can't return tuple. how can I return values? why I can't return tuple? In D, tuple is not built in type, it