Re: std.typecons rebindable + tuple with const class gives warning

2021-02-17 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 4 February 2021 at 20:40:43 UTC, tsbockman wrote: TLDR; Either make `c` mutable, or override/overload the `C` associative array support methods `toHash` and `opEquals` to support `const(C)` objects. This solved my issue. I finally understood why this was happening after

std.typecons rebindable + tuple with const class gives warning

2021-02-04 Thread Saurabh Das via Digitalmars-d-learn
This code: void main() { import std.typecons : rebindable, tuple; const c = new C(); auto t = tuple(c.rebindable); } class C { } When compiled with DMD 2.095.0 gives a warning: Warning: struct Rebindable has method toHash, however it cannot be called with

Re: dmd -O causes incorrect output

2021-01-25 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 25 January 2021 at 19:18:47 UTC, H. S. Teoh wrote: On Mon, Jan 25, 2021 at 06:45:43PM +, Saurabh Das via Digitalmars-d-learn wrote: On Monday, 25 January 2021 at 18:19:24 UTC, H. S. Teoh wrote: [...] > It's probably a bug. File a bug on bugzilla: > https://issues.dla

Re: dmd -O causes incorrect output

2021-01-25 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 25 January 2021 at 18:19:24 UTC, H. S. Teoh wrote: On Mon, Jan 25, 2021 at 06:07:46PM +, Saurabh Das via Digitalmars-d-learn wrote: [...] [...] [...] It's probably a bug. File a bug on bugzilla: https://issues.dlang.org [...] [...] DMD's backend is known to have

dmd -O causes incorrect output

2021-01-25 Thread Saurabh Das via Digitalmars-d-learn
I'm seeing what appears to be a bug with the -O flag in dmd. Here is a reduced test case: struct SomeStruct { long value; } bool isNumberOne(int i) { SomeStruct l; if(i == 1) l = SomeStruct(10); return (l == SomeStruct(10)); } void main() { if

Re: Surprising behaviour of std.experimental.allocator

2020-12-27 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 26 December 2020 at 19:36:24 UTC, ag0aep6g wrote: On 26.12.20 13:59, ag0aep6g wrote: Looks like a pretty nasty bug somewhere in std.experimental.allocator or (less likely) the GC. Further reduced code: [...] Apparently, something calls deallocateAll on a Mallocator

Re: Surprising behaviour of std.experimental.allocator

2020-12-24 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 24 December 2020 at 23:58:45 UTC, Elronnd wrote: On Thursday, 24 December 2020 at 23:46:58 UTC, Elronnd wrote: reduced version: Further reduction: Alloc1 can just be ‘AllocatorList!(n => Region!Mallocator(MB))’. Thank you for the reduced test case. A small change to the test

Surprising behaviour of std.experimental.allocator

2020-12-24 Thread Saurabh Das via Digitalmars-d-learn
This causes a segfault when run with rdmd -gx: void main() { import std.experimental.allocator : allocatorObject, expandArray; import std.experimental.allocator.building_blocks.allocator_list : AllocatorList; import std.experimental.allocator.building_blocks.region : Region;

Re: core.atomic.atomicStore and structs

2020-03-03 Thread Saurabh Das via Digitalmars-d-learn
On Tuesday, 3 March 2020 at 11:35:35 UTC, MoonlightSentinel wrote: On Tuesday, 3 March 2020 at 11:04:53 UTC, Saurabh Das wrote: PS: Any chance this will make it into DMD 2.091.0? Yes, this fix will be in the upcoming release. Excellent. Thank you so much! :) Saurabh

Re: core.atomic.atomicStore and structs

2020-03-03 Thread Saurabh Das via Digitalmars-d-learn
On Tuesday, 3 March 2020 at 10:57:36 UTC, MoonlightSentinel wrote: On Tuesday, 3 March 2020 at 09:12:40 UTC, Saurabh Das wrote: Is this supposed to not work anymore? Or is this a bug? That is a bug, see https://issues.dlang.org/show_bug.cgi?id=20629 Oh wow you fixed it already! Amazing!

core.atomic.atomicStore and structs

2020-03-03 Thread Saurabh Das via Digitalmars-d-learn
Hi, Consider this code: ``` import core.atomic; struct MyStruct { uint a, b; } static assert(MyStruct.sizeof == ulong.sizeof); void main() { shared MyStruct ms1; MyStruct ms2 = atomicLoad(ms1); // This is fine MyStruct ms3; cas(, ms2, ms3);// This is

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-03 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 2 February 2020 at 06:03:01 UTC, H. S. Teoh wrote: On Sun, Feb 02, 2020 at 03:16:46AM +, Saurabh Das via Digitalmars-d-learn wrote: [...] [...] > [...] [...] [...] [...] It's very simple. Let's say you have your code in some string called 'code'. Since dmd nowadays

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 1 February 2020 at 20:37:03 UTC, H. S. Teoh wrote: On Sat, Feb 01, 2020 at 08:01:34PM +, Andre Pany via Digitalmars-d-learn wrote: [...] Another approach: - include the dmd compiler package with your application - within your app call the compiler executable and compile the

Re: Unexpected issue with std.format

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 1 February 2020 at 15:16:41 UTC, Steven Schveighoffer wrote: On 2/1/20 8:39 AM, Saurabh Das wrote: I faced this issue while working with custom formatting for a struct. I have reduced the error down to this test program: import std.format, std.stdio, std.array; struct Test1 {   

Re: Unexpected issue with std.format

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 1 February 2020 at 13:39:34 UTC, Saurabh Das wrote: I faced this issue while working with custom formatting for a struct. I have reduced the error down to this test program: [...] PS: Currently using DMD64 D Compiler v2.090.0

Unexpected issue with std.format

2020-02-01 Thread Saurabh Das via Digitalmars-d-learn
I faced this issue while working with custom formatting for a struct. I have reduced the error down to this test program: import std.format, std.stdio, std.array; struct Test1 { void toString(W, C)(ref W w, scope const ref FormatSpec!C fmt) { pragma(msg, "Test1 function

Re: Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote: On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote: [...] Fundamentally DMD as a library is a front-end. Jitting is to the backend side. You'll be able to lex and parse the source to get an AST, to perform the semantic

Is it possible to use DMD as a library to compile strings at runtime?

2020-01-31 Thread Saurabh Das via Digitalmars-d-learn
I see that DUB has DMD as a library package, but I was not able to understand how to use it. Is it possible to use DMD as a library within a D program to compile a string to machine code and run the compiled code at runtime? Thanks, Saurabh

Is there any implementation of a 128bit integer?

2019-08-19 Thread Saurabh Das via Digitalmars-d-learn
The cent and ucent types are reserved for the future. Is there any knowledge/timeline on when they might be implemented? Currently, is there a useable 128bit integer type in DMD/LDC/GDC? Or perhaps a library that implements 128bit integers? I've come across gfm:integers

Re: Bug with writeln?

2018-09-09 Thread Saurabh Das via Digitalmars-d-learn
Thank you for explaining all this. It is frustrating because the behaviour is very counterintuitive. I will use a workaround for now. Saurabh

Bug with writeln?

2018-09-06 Thread Saurabh Das via Digitalmars-d-learn
Is this a bug with writeln? void main() { import std.stdio, std.range, std.algorithm; auto a1 = sort([1,3,5,4,2]); auto a2 = sort([9,8,9]); auto a3 = sort([5,4,5,4]); pragma(msg, typeof(a1)); pragma(msg, typeof(a2)); pragma(msg, typeof(a3)); auto b = [a1, a2,

Scalars in ndslice?

2017-11-25 Thread Saurabh Das via Digitalmars-d-learn
I've been using ndslice for some timeseries work and it's incredibly good. One question which I couldn't find an answer to: Can ndslice behave as a scalar (ie: 0-dimensional slice)? It would be convenient if that is possible since then I won't have to write different functions for scalars

Re: Huge increase in UT compile time

2017-10-14 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 14 October 2017 at 09:03:05 UTC, Joakim wrote: On Saturday, 14 October 2017 at 04:36:25 UTC, Saurabh Das wrote: [...] I can reproduce on linux/x64, looks like a memory leak, as dmd balloons out to eat up all available memory until it's killed. I see it with this minimal

Re: Huge increase in UT compile time

2017-10-13 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 08:11:37 UTC, Jonathan M Davis wrote: On Wednesday, October 11, 2017 06:25:19 Dhananjay via Digitalmars-d-learn wrote: Hello, I am upgrading to DMD 2.076.1 from DMD 2.069.2 (similar results on 2.075.1), and seeing a huge increase in unittest compilation time

Re: Funny issue with casting double to ulong

2017-07-02 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: [...] 6.251 has no perfect double representation. It's real value is: 6.215099962483343551867E0 Hence when you cast to ulong after the product by 10_000, this is

Funny issue with casting double to ulong

2017-07-02 Thread Saurabh Das via Digitalmars-d-learn
Consider this snippet: void main() { import std.stdio; auto a = 6.2151; auto b = a * 1; auto c = cast(ulong)b; writeln("a: ", typeof(a).stringof, " ", a); writeln("b: ", typeof(b).stringof, " ", b); writeln("c: ", typeof(c).stringof, " ", c); auto x =

Re: Need some help understanding PyD

2017-01-08 Thread Saurabh Das via Digitalmars-d-learn
PS: Noticed something off. My python installation is 3.4.3: Python 3.4.3 (default, Sep 14 2016, 12:36:27) [GCC 4.8.4] on linux However when I run: context.py_stmts("import sys"); context.py_stmts("print(sys.version)"); I get: 3.4.0 (default, Apr 11 2014, 13:08:40) [GCC 4.8.2] Also,

Need some help understanding PyD

2017-01-08 Thread Saurabh Das via Digitalmars-d-learn
I've been giving PyD a try. It's really nice and mostly everything works out of the box. I'm trying to use TensorFlow in D via Pytho, so I need to call Python functions in D. When I try to do: auto context = new InterpContext(); context.py_stmts("import tensorflow"); I get this

Re: Vibe.D - log requests and responses

2016-11-24 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 24 November 2016 at 07:57:47 UTC, Jacob Carlborg wrote: On 2016-11-24 07:29, Saurabh Das wrote: [...] Yes. You can configure the logging on the HTTPServerSettings [1] instance. If you look at the documentation, the first four fields are related to logging. Use "accessLogFile"

Vibe.D - log requests and responses

2016-11-23 Thread Saurabh Das via Digitalmars-d-learn
Hi, Is there an easy way to log all incoming requests and outgoing responses (and perhaps processing time, wait time, etc) in Vibe.D? Thanks, Saurabh

Re: Concatenate 2 ranges

2016-11-11 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 11 November 2016 at 13:30:17 UTC, RazvanN wrote: I am trying to concatenate 2 ranges of the same type (SortedRange in my case). I have tried merge, join and chain, but the problem is that the result is not an object of the type of the initial ranges. For example: 1. If I use

Re: Neural Networks / ML Libraries for D

2016-10-25 Thread Saurabh Das via Digitalmars-d-learn
On Tuesday, 25 October 2016 at 14:31:39 UTC, bachmeier wrote: On Tuesday, 25 October 2016 at 13:58:33 UTC, Saurabh Das wrote: [...] Installation amounts to installing a couple of R packages that I have on Bitbucket, as described on the project page. I have basic usage examples there as

Re: Neural Networks / ML Libraries for D

2016-10-25 Thread Saurabh Das via Digitalmars-d-learn
On Tuesday, 25 October 2016 at 13:26:49 UTC, bachmeier wrote: On Tuesday, 25 October 2016 at 11:17:29 UTC, Saurabh Das wrote: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh I

Re: Neural Networks / ML Libraries for D

2016-10-25 Thread Saurabh Das via Digitalmars-d-learn
(a C library) together with D and it worked very well. 2016-10-25 13:17 GMT+02:00 Saurabh Das via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com>: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads

Neural Networks / ML Libraries for D

2016-10-25 Thread Saurabh Das via Digitalmars-d-learn
Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh

Re: Repeat and chunks

2016-10-24 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 24 October 2016 at 15:59:05 UTC, Meta wrote: On Monday, 24 October 2016 at 15:28:50 UTC, Saurabh Das wrote: [...] Yes, that's correct. This is the overload of `repeat` in question: https://dlang.org/phobos/std_range.html#.repeat.2 Take!(Repeat!T) repeat(T)(T value, size_t n);

Re: Repeat and chunks

2016-10-24 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 24 October 2016 at 15:28:50 UTC, Saurabh Das wrote: On Monday, 24 October 2016 at 14:25:46 UTC, Dorian Haglund wrote: Hey, The following code crashes with DMD64 D Compiler v2.071.2: import std.algorithm; import std.stdio; import std.range; int main() { repeat(8,

Re: Repeat and chunks

2016-10-24 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 24 October 2016 at 14:25:46 UTC, Dorian Haglund wrote: Hey, The following code crashes with DMD64 D Compiler v2.071.2: import std.algorithm; import std.stdio; import std.range; int main() { repeat(8, 10).chunks(3).writeln(); return 0; } Error message: pure nothrow @nogc

Re: Vibe.d compilation error: backend/cgelem.c 5018 dmd failed with exit code 1.

2016-09-22 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 22 September 2016 at 10:44:29 UTC, llaine wrote: On Wednesday, 21 September 2016 at 21:32:02 UTC, Rene Zwanenburg wrote: On Wednesday, 21 September 2016 at 20:22:42 UTC, llaine wrote: Yes, but it may take some time. For large projects, running it on a server is advisable. 3K LOC

Re: Vibe.d compilation error: backend/cgelem.c 5018 dmd failed with exit code 1.

2016-09-21 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 14:15:30 UTC, llaine wrote: Using dmd every day and since one day I'm getting this error when I'm compiling using the -b release flag (dub build -b release). I'm compiling a vibe.d application that has roughly 3k LoC. Removing the -b flag solves the

Re: What blogs about D do you read?

2016-09-20 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 19 September 2016 at 19:36:22 UTC, Karabuta wrote: On Monday, 19 September 2016 at 19:29:25 UTC, A D dev wrote: On Monday, 19 September 2016 at 17:42:51 UTC, A D dev wrote: Hi list, What blogs about D do you read? To be more clear: - what blogs that include posts on D, would you

Re: Log in an @nogc function

2016-08-17 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 17 August 2016 at 10:47:54 UTC, Guillaume Piolat wrote: On Wednesday, 17 August 2016 at 10:45:01 UTC, Saurabh Das wrote: Is there any way I can log to a terminal or a file from inside an @nogc function? Thanks, Saurabh import core.stdc.stdio; printf("am logging C-style\n");

Log in an @nogc function

2016-08-17 Thread Saurabh Das via Digitalmars-d-learn
Is there any way I can log to a terminal or a file from inside an @nogc function? Thanks, Saurabh

Re: Replace (ie: substitute) a type in varadic args

2016-08-02 Thread Saurabh Das via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote: On Tuesday, 2 August 2016 at 07:24:28 UTC, Saurabh Das wrote: [...] Just of the top of my head, using ugly string mixins, this: auto myConverterFunc(Args...)(Args args) { string genCode() { string code

Re: Replace (ie: substitute) a type in varadic args

2016-08-02 Thread Saurabh Das via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 08:20:22 UTC, Saurabh Das wrote: On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote: [...] Thanks. Yes that is one approach. I figured out another approach that seems decent: auto targetFunctionProxy(Args...)(Args args) { import std.meta;

Replace (ie: substitute) a type in varadic args

2016-08-02 Thread Saurabh Das via Digitalmars-d-learn
How can I substitute the type of an argument received via a varadic template? For example say I want to generalise this scenario: auto myConverterFunction1(bool arg1, bool arg2, ubyte arg3, int arg4) { return targetFunction(cast(ubyte)arg1, cast(ubyte)arg2, arg3, arg4); } So I'll have

Re: Default implementations in inherited interfaces

2016-07-25 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 24 July 2016 at 07:54:11 UTC, Jonathan Marler wrote: On Thursday, 21 July 2016 at 13:37:30 UTC, Saurabh Das wrote: On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: Java 8 has a 'default' keyword that allows

Re: Default implementations in inherited interfaces

2016-07-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote: On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote: I have an interface A which declares a certain function. A second interface B inherits from A and wishes to provide a default implementation for that function. You

Default implementations in inherited interfaces

2016-07-21 Thread Saurabh Das via Digitalmars-d-learn
I have an interface A which declares a certain function. A second interface B inherits from A and wishes to provide a default implementation for that function. How can I achieve this? I'm facing an error when I try this: interface A { int func(int); } interface B : A { final int

Re: Mono-D for the new Xamarin Studio

2016-06-10 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 10 June 2016 at 13:36:43 UTC, Alex Bothe wrote: On Friday, 10 June 2016 at 12:51:34 UTC, Saurabh Das wrote: I have foolishly updated my Xamarin Studio and now the D Language Binding no longer works. Is there an update to fix this? Or should I downgrade? Thanks, Saurabh Hi there,

Mono-D for the new Xamarin Studio

2016-06-10 Thread Saurabh Das via Digitalmars-d-learn
I have foolishly updated my Xamarin Studio and now the D Language Binding no longer works. Is there an update to fix this? Or should I downgrade? Thanks, Saurabh

Re: Is there a 128-bit integer in D?

2016-05-22 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 22 May 2016 at 09:07:32 UTC, Guillaume Piolat wrote: On Sunday, 22 May 2016 at 07:40:08 UTC, Nicholas Wilson wrote: On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote: I see that 'cent' and 'ucent' are reserved for future use but not yet implemented. Does anyone have a

Re: Is there a 128-bit integer in D?

2016-05-21 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 21 May 2016 at 21:51:34 UTC, Jonathan M Davis wrote: On Saturday, May 21, 2016 09:43:38 Saurabh Das via Digitalmars-d-learn wrote: I see that 'cent' and 'ucent' are reserved for future use but not yet implemented. Does anyone have a working implementation of these types

Is there a 128-bit integer in D?

2016-05-21 Thread Saurabh Das via Digitalmars-d-learn
I see that 'cent' and 'ucent' are reserved for future use but not yet implemented. Does anyone have a working implementation of these types? Alternatively, is there an any effort towards implementation of arbitrary-sized integers in Phobos? Thanks, Saurabh

Re: Using shorthand *= leads to unexpected result?

2016-05-15 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 15 May 2016 at 13:25:42 UTC, Michael wrote: Well I'm pretty sure the code was working just fine earlier in the week at the office, but running the code at home with the newest version of DMD started producing these odd results. Typing this function into asm.dlang.org shows a minor

Re: Using shorthand *= leads to unexpected result?

2016-05-15 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 15 May 2016 at 13:01:45 UTC, Michael wrote: It may be that I'm doing something wrong here, but after updating DMD to the latest version, my simulations started producing some very odd results and I think I've pinpointed it to a sign inversion that I was making. Here is some code

Re: nanosecond time

2016-02-14 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 13 February 2016 at 19:24:44 UTC, ishwar wrote: I am stumped on need finding interval between two events in a program execution in nanoseconds. Any sample code will be appreciated (along with imports needed to make it work): - time in nanoseconds-now - do-some processing - time

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 10 February 2016 at 00:24:56 UTC, tsbockman wrote: [...] `Tuple.slice` is corrupting data *right now*. Some sort of short-term fix should be merged in the next release of D. +1

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread Saurabh Das via Digitalmars-d-learn
On Sunday, 7 February 2016 at 02:51:49 UTC, tsbockman wrote: On Sunday, 7 February 2016 at 02:11:15 UTC, Marco Leise wrote: I understand that. We just have a different perspective on the problem. Your priorities: - don't break what's not broken - .slice! lends on opSlice and should return by

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-06 Thread Saurabh Das via Digitalmars-d-learn
On Saturday, 6 February 2016 at 08:01:20 UTC, tsbockman wrote: On Saturday, 6 February 2016 at 06:34:05 UTC, Marco Leise wrote: [...] I should also point out that, since there is no way to actually find out whether anyone is using the `ref`-ness of the return type in the wild, the approach

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-05 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 5 February 2016 at 19:16:11 UTC, Marco Leise wrote: Am Fri, 05 Feb 2016 05:31:15 + schrieb Saurabh Das : [...] That is enlightening. I have updated the PR at https://github.com/D-Programming-Language/phobos/pull/3975 to incorporate these changes.

Is this a bug in std.typecons.Tuple.slice?

2016-02-04 Thread Saurabh Das via Digitalmars-d-learn
This code: void main() { import std.typecons; auto tp = tuple!("a", "b", "c")(10, false, "hello"); auto u0 = tp.slice!(0, tp.length); auto u1 = tp.slice!(1, tp.length); auto u2 = tp.slice!(2, tp.length); static assert(is(typeof(u0) == Tuple!(int, "a", bool, "b",

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-04 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 4 February 2016 at 17:52:16 UTC, Marco Leise wrote: https://issues.dlang.org/show_bug.cgi?id=15645 Thank you. I understood why this is happening from your explanation in the bug report.

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-04 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 4 February 2016 at 12:28:39 UTC, Saurabh Das wrote: This code: [...] Update: Simplified, this also doesn't work: void main() { import std.typecons; auto tp = tuple(10, false, "hello"); auto u0 = tp.slice!(0, tp.length); auto u1 = tp.slice!(1, tp.length); auto

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-04 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 4 February 2016 at 17:52:16 UTC, Marco Leise wrote: https://issues.dlang.org/show_bug.cgi?id=15645 Is this a possible fixed implementation? : @property Tuple!(sliceSpecs!(from, to)) slice(size_t from, size_t to)() @trusted const if (from <= to && to <=

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-04 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 5 February 2016 at 05:18:01 UTC, Saurabh Das wrote: [...] Apologies for spamming. This is an improved implementation: @property Tuple!(sliceSpecs!(from, to)) slice(size_t from, size_t to)() @safe const if (from <= to && to <= Types.length) {

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-04 Thread Saurabh Das via Digitalmars-d-learn
On Friday, 5 February 2016 at 05:18:01 UTC, Saurabh Das wrote: [...] PS: Additionally, '@trusted' can now be substituted with '@safe'.

Re: std.typecons.Proxy requires a nothrow destructor and toHash?

2016-02-03 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 12:10:01 UTC, Marc Schütz wrote: On Wednesday, 3 February 2016 at 10:16:56 UTC, Saurabh Das wrote: [...] It used to work in 2.066.1; bisecting points to this PR: https://github.com/D-Programming-Language/phobos/pull/3043 When bisecting between 2.066 and

Re: How should I do object serialization?

2016-01-27 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 28 January 2016 at 04:27:31 UTC, Enjoys Math wrote: I'm not looking for anything advanced, just serialization of some of my own types (classes & structs). I've seen: http://wiki.dlang.org/Review/std.serialization However, I don't see std.serialization in my dmd source tree:

Re: Speed of csvReader

2016-01-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:32:52 UTC, Saurabh Das wrote: On Thursday, 21 January 2016 at 13:42:11 UTC, Edwin van Leeuwen wrote: On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: StopWatch sw; sw.start(); auto buffer =

Re: Speed of csvReader

2016-01-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 January 2016 at 13:42:11 UTC, Edwin van Leeuwen wrote: On Thursday, 21 January 2016 at 09:39:30 UTC, data pulverizer wrote: StopWatch sw; sw.start(); auto buffer = std.file.readText("Acquisition_2009Q2.txt"); auto records = csvReader!row_type(buffer, '|').array;

Re: Speed of csvReader

2016-01-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 January 2016 at 17:10:39 UTC, data pulverizer wrote: On Thursday, 21 January 2016 at 16:01:33 UTC, wobbles wrote: Interesting that reading a file is so slow. Your timings from R, is that including reading the file also? Yes, its just insane isn't it? It is insane. Earlier

Using std.conv.to with std.typecons.Typedef

2016-01-11 Thread Saurabh Das via Digitalmars-d-learn
I am trying to create 2 types which contain integral values but should not be compatible with each other. std.typecons.Typedef seems perfect for this: alias QuestionId = Typedef!(long, long.init, "QuestionId"); alias StudentId = Typedef!(long, long.init, "StudentId"); However I'm failing to

Re: Using std.conv.to with std.typecons.Typedef

2016-01-11 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 11 January 2016 at 12:01:30 UTC, Tobi G. wrote: On Monday, 11 January 2016 at 08:03:19 UTC, Saurabh Das wrote: How can I get std.conv to understand std.typecons.Typedef? You can do something like this: QuestionId q = to!(TypedefType!QuestionId)("43"); In general, is there a

Re: Using std.conv.to with std.typecons.Typedef

2016-01-11 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 11 January 2016 at 12:59:05 UTC, Tobi G. wrote: On Monday, 11 January 2016 at 12:15:55 UTC, Saurabh Das wrote: Any ideas? Yes. Because Typedef is introducing new Types, which csvReader doesn't know what they are, you'll need a little workaround and cast the values yourself.

Segfault while compiling simple program

2015-12-16 Thread Saurabh Das via Digitalmars-d-learn
struct xlref { ushort rwFirst; ushort rwLast; ubyte colFirst; ubyte colLast; } struct xlmref { ushort count; xlref reflist; } Mac OS X (dmd 2.069.0) === dmd dprob.d Segmentation fault: 11 Windows (dmd 2.069.2) == dmd -v -m64 dprob.d

Re: Segfault while compiling simple program

2015-12-16 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 16 December 2015 at 09:38:24 UTC, Ali Çehreli wrote: On 12/16/2015 01:26 AM, Saurabh Das wrote: struct xlref { ushort rwFirst; ushort rwLast; ubyte colFirst; ubyte colLast; } struct xlmref { ushort count; xlref reflist; } Mac OS X (dmd 2.069.0)

Re: Segfault while compiling simple program

2015-12-16 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 16 December 2015 at 10:07:38 UTC, Saurabh Das wrote: On Wednesday, 16 December 2015 at 09:38:24 UTC, Ali Çehreli wrote: On 12/16/2015 01:26 AM, Saurabh Das wrote: struct xlref { ushort rwFirst; ushort rwLast; ubyte colFirst; ubyte colLast; } struct xlmref {

Internal Compiler Error Help

2015-05-21 Thread Saurabh Das via Digitalmars-d-learn
Hello, We have been working on a genetic programming project, and occasionally the compiler fails and gives an internal error. I've captured and reduced one of these down to a single expression. See http://dpaste.dzfl.pl/e7a66aa067ab (reduced_expr.d) When I compile this file using: dmd -c

Re: Internal Compiler Error Help

2015-05-21 Thread Saurabh Das via Digitalmars-d-learn
Thanks! Wow, dustmite is really useful. It reduces the expression down to: double someFunction(double AvgPriceChangeNormalized, double TicksTenMinutesNormalized) { return (TicksTenMinutesNormalized?1:AvgPriceChangeNormalized)?1:TicksTenMinutesNormalized/(TicksTenMinutesNormalized==0)==0;

Re: Internal Compiler Error Help

2015-05-21 Thread Saurabh Das via Digitalmars-d-learn
PS: The original expression: http://dpaste.dzfl.pl/raw/e7a66aa067ab double someFunction(double AvgPriceChangeNormalized, double DayFactor, double TicksTenMinutesNormalized) { return

Re: Internal Compiler Error Help

2015-05-21 Thread Saurabh Das via Digitalmars-d-learn
and please submit to https://issues.dlang.org Submitted: https://issues.dlang.org/show_bug.cgi?id=14613 That expression is, not to put too fine a point on it, mad. The operator precedence itself is giving me a headache, let alone the division of a double by a boolean... I'm pretty sure

Re: Internal Compiler Error Help

2015-05-21 Thread Saurabh Das via Digitalmars-d-learn
fair enough. I thought normally you'd want to have some sort of expression simplification in genetic programming, to avoid adding too many superfluous degrees of freedom? Aside from the obvious problems, those extra degrees of freedom can put you at risk of overfitting. Yes - our

Re: Internal Compiler Error Help

2015-05-21 Thread Saurabh Das via Digitalmars-d-learn
On Thursday, 21 May 2015 at 14:12:25 UTC, Kagamin wrote: If you're looking for speed, how about ldc? Absolutely - we are working on getting it to compile on ldc and/or gdc.