Re: Objective C protocols

2020-05-17 Thread John Colvin via Digitalmars-d-learn
On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote: What's the best way to implement an Objective C protocol in D? I see mention here https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days. Based on some experimentation,

Objective C protocols

2020-05-16 Thread John Colvin via Digitalmars-d-learn
What's the best way to implement an Objective C protocol in D? I see mention here https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days.

Re: A proper WAT moment

2019-10-15 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 October 2019 at 19:45:11 UTC, Paul Backus wrote: On Monday, 14 October 2019 at 17:00:56 UTC, John Colvin wrote: Different ability to access a property depending if I'm inside something else when I look? [snip] You're attempting to call one of S's member functions without an

A proper WAT moment

2019-10-14 Thread John Colvin via Digitalmars-d-learn
Different ability to access a property depending if I'm inside something else when I look? struct S { int a; static int b; int c() { return a; } static int d() { return 3; } int e() @property { return a; } static int f() @property { return 3; } } void foo(S s) {

How to find what is causing a closure allocation

2019-10-02 Thread John Colvin via Digitalmars-d-learn
I have a function that allocates a closure somewhere in it (as shown by the result of -profile=gc). I can't make the function nogc as it calls a lot of other GC using code. profilegc.log only gives me the line number of the function signature, which doesn't give me any hint as to where in

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Sunday, 11 August 2019 at 20:15:34 UTC, Alex wrote: On Sunday, 11 August 2019 at 16:05:20 UTC, John Colvin wrote: I'm trying to narrow down exactly what patterns work with each and how they overlap. What I was trying to get at with the abstract method thing is that abstract class C {

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Sunday, 11 August 2019 at 15:16:03 UTC, Alex wrote: On Sunday, 11 August 2019 at 13:09:43 UTC, John Colvin wrote: Ok. What would go wrong (in D) if I just replaced every interface with an abstract class? I think there's some confusion here, because B.foo is not abstract. abstract on a

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 17:28:32 UTC, Alex wrote: ´´´ void main(){} interface A { void fun(); } abstract class B{ void fun(); } class C : A{ void fun(){} } class D : B{ /*override*/ void fun(){} } ´´´ case 1: interface A and class C implementing interface A: You don't need to "override"

Re: Abstract classes vs interfaces, casting from void*

2019-08-11 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 17:46:37 UTC, Timon Gehr wrote: On 10.08.19 16:29, John Colvin wrote: Ok. What would go wrong (in D) if I just replaced every interface with an abstract class? interface A{} interface B{} class C: A,B{ } Yes, I know, I guess it wasn't clear unless you read

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 10:11:15 UTC, Alex wrote: On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract class?

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Saturday, 10 August 2019 at 10:02:02 UTC, Antonio Corbi wrote: On Saturday, 10 August 2019 at 08:20:46 UTC, John Colvin wrote: On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: Thanks for the extra detail. Is there a solid reason to ever use an interface over an abstract class? (Other than multiple inheritance). I'm such a noob at anything related to OO.

Re: Abstract classes vs interfaces, casting from void*

2019-08-10 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 August 2019 at 13:39:53 UTC, Simen Kjærås wrote: We're getting into somewhat advanced topics now. This is described in the Application Binary Interface page of the documentation[0]. In short: classes and interfaces both use a vtable[1] that holds pointers to each of their methods.

Re: Abstract classes vs interfaces, casting from void*

2019-08-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 August 2019 at 13:19:14 UTC, kinke wrote: On Friday, 9 August 2019 at 12:26:59 UTC, John Colvin wrote: Why is there no "hi" between 0 and 1? Because you are treating the unadjusted object pointer as interface pointer and then call the only virtual function of that interface, in

Abstract classes vs interfaces, casting from void*

2019-08-09 Thread John Colvin via Digitalmars-d-learn
import std.stdio; interface I { void foo(); } class C : I { override void foo() { writeln("hi"); } } abstract class AC { void foo(); } class D : AC { override void foo() { writeln("hi"); } } void main() { auto c = new C(); writeln(0); (cast(I)cast(void*)c).foo();

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-09 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 8 May 2019 at 11:53:34 UTC, Russel Winder wrote: On Mon, 2019-05-06 at 15:53 +, John Colvin via Digitalmars-d-learn wrote: […] pretty please show people it with UFCS: recurrence!((a, n) => a[n-1] + a[n-2])(zero, one) .dropExactly(n) .front Any particular rea

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-06 Thread John Colvin via Digitalmars-d-learn
On Monday, 6 May 2019 at 13:05:27 UTC, Russel Winder wrote: On Sunday, 5 May 2019 at 19:34:05 UTC, Nicholas Wilson wrote: On Sunday, 5 May 2019 at 19:18:47 UTC, lithium iodate wrote: [...] Yep https://run.dlang.io/is/XsLrRz works for me, https://run.dlang.io/is/KxY0e9 doesn't. Thanks

Re: Idiomatic FFT(W) Wrapper

2017-07-13 Thread John Colvin via Digitalmars-d-learn
On Thursday, 13 July 2017 at 12:49:40 UTC, Per Nordlöw wrote: Have anybody constructed an idiomatic D wrapper for FFTW? No, sorry, although I have used the library quite a bit in D. http://www.fftw.org/fftw3_doc/Tutorial.html#Tutorial I'm specifically concerned about -

Re: Finding the index of the maximum value in an associative array

2017-06-01 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 18:05:07 UTC, H. S. Teoh wrote: On Tue, May 30, 2017 at 05:57:04PM +, Lyle via Digitalmars-d-learn wrote: Hi, I have an associative array of type int[ulong] and I'm trying to get the index of the maximum value, like this: int[ulong] aa = [1UL: 2000,

Re: Access specifiers and visibility

2017-05-13 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 01:42:47 UTC, Andrew Edwards wrote: Attempting to update a git repo to current D, I encounter the following deprecation messages: src/glwtf/signals.d-mixin-256(256,2): Deprecation: glwtf.input.BaseGLFWEventHandler._on_key_down is not visible from module

Re: List Comprehension equivalent

2017-03-17 Thread John Colvin via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:08:36 UTC, Russel Winder wrote: On Fri, 2017-03-17 at 17:51 +, Jerry via Digitalmars-d-learn wrote: On Friday, 17 March 2017 at 17:13:48 UTC, Russel Winder wrote: > I have a bit of code: > > string[] returnValue; >foreach(string key, string[] value;

Re: In Expressions

2017-03-04 Thread John Colvin via Digitalmars-d-learn
On Saturday, 4 March 2017 at 17:11:46 UTC, Andrey wrote: Hello, is there any way to using in expression like in python, e.g. if 4 in [1, 3, 4]: do something My code in D if (regionAlign in [RegionAlign.top, RegionAlign.bottom]) { ... } throws an error: incompatible types for

Re: template parameter inference and introspection

2017-02-24 Thread John Colvin via Digitalmars-d-learn
On Friday, 24 February 2017 at 14:06:22 UTC, Meta wrote: On Friday, 24 February 2017 at 11:17:46 UTC, John Colvin wrote: Unfortunately that only works by accident of my example. A counterexample: T foo(Q = float, T = short)(T t) { return t; } alias Typeof(alias v) = typeof(v); template

Re: template parameter inference and introspection

2017-02-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 23 February 2017 at 18:33:33 UTC, Meta wrote: On Thursday, 23 February 2017 at 18:21:51 UTC, Meta wrote: On Thursday, 23 February 2017 at 16:01:44 UTC, John Colvin wrote: Is there any way to get a reference/alias to the instantiation of a template function that would be called,

template parameter inference and introspection

2017-02-23 Thread John Colvin via Digitalmars-d-learn
Is there any way to get a reference/alias to the instantiation of a template function that would be called, given certain parameters? I.e. to get the result of whatever template parameter inference (and overload resolution) has occurred? E.g. for some arbitrarily complex foo: static

Re: Alias type with different initialiser.

2017-02-14 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 14 February 2017 at 11:34:22 UTC, Bastiaan Veelo wrote: On Monday, 13 February 2017 at 22:59:11 UTC, John Colvin wrote: Why not use a constructor instead of static opCall? I don't know, this comes from http://dlang.org/spec/struct.html#dynamic_struct_init. Your constructor looks

Re: Alias type with different initialiser.

2017-02-14 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 14 February 2017 at 10:49:19 UTC, Bastiaan Veelo wrote: On Tuesday, 14 February 2017 at 01:31:10 UTC, John Colvin wrote: On Monday, 13 February 2017 at 22:59:11 UTC, John Colvin wrote: [ snip ] sorry, made a typo, that should have been alias int1 = Initial!(int, 1);

Re: Alias type with different initialiser.

2017-02-13 Thread John Colvin via Digitalmars-d-learn
On Monday, 13 February 2017 at 22:59:11 UTC, John Colvin wrote: [ snip ] sorry, made a typo, that should have been alias int1 = Initial!(int, 1); static assert(int1.initial == 1); // typeof(int1.initial) == int static assert(int1.init == 1); // typeof(int1.init) == int1

Re: Alias type with different initialiser.

2017-02-13 Thread John Colvin via Digitalmars-d-learn
On Monday, 13 February 2017 at 22:16:36 UTC, Bastiaan Veelo wrote: On Monday, 13 February 2017 at 16:40:02 UTC, Daniel Kozak wrote: https://dlang.org/phobos/std_typecons.html#.Typedef Thanks for the pointers. Both Typedef and Proxy create types that don't mix with the base type, which I want

Re: Associative array literal: length wrong when duplicate keys found

2017-01-31 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 31 January 2017 at 14:15:58 UTC, Ivan Kazmenko wrote: Hi. I wanted to check whether a few variables of the same type are all distinct, in a quick and dirty way. I tried to do it similar to Python's "len(set(value_list)) == len(value_list)" idiom by using an associative array

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2016-11-27 Thread John Colvin via Digitalmars-d-learn
On Saturday, 26 November 2016 at 17:37:57 UTC, Paolo Invernizzi wrote: This is stated in documentation [1]: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; unittest { assert(aa["foo"] == 5); assert(aa["bar"] == 10); assert(aa["baz"] == 2000); } But results

Re: Updated D then undefined symbols in vibed

2016-11-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 November 2016 at 09:52:32 UTC, Jot wrote: Using vibe D. designed to update dmd to latest and then I now get the following errors: .dub\obj\debug\dev\source\app.obj(app) Error 42: Symbol Undefined _D3std6format12arrayPtrDiffFNaNbNiNexAvxAvZi

Re: Array operations with multidimensional arrays

2016-11-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 19:36:50 UTC, Marduk wrote: On Saturday, 19 November 2016 at 17:37:58 UTC, John Colvin wrote: On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote: Additionally, I would like to assign 2D sub-arrays of a 3D array, i.e. something like the following:

Re: Array operations with multidimensional arrays

2016-11-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote: Additionally, I would like to assign 2D sub-arrays of a 3D array, i.e. something like the following: int[3][2][2] a; a[0] = [[2,2], [2,2]]; You have the dimensions the wrong way around. a is a 2 element array of 2 element arrays

Re: splitter trouble

2016-11-01 Thread John Colvin via Digitalmars-d-learn
On Sunday, 30 October 2016 at 23:57:11 UTC, Ali Çehreli wrote: While working on a solution for Alfred Newman's thread, I came up with the following interim solution, which compiled but failed: auto parse(R, S)(R range, S separators) { import std.algorithm : splitter, filter, canFind;

Re: Draw math formulas with ggplotd

2016-09-17 Thread John Colvin via Digitalmars-d-learn
On Saturday, 17 September 2016 at 12:09:04 UTC, Edwin van Leeuwen wrote: On Saturday, 17 September 2016 at 11:57:17 UTC, John Colvin wrote: On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote: But I assumed he meant adding the formula onto the plot. Hah, yes, I should

Re: Draw math formulas with ggplotd

2016-09-17 Thread John Colvin via Digitalmars-d-learn
On Saturday, 17 September 2016 at 11:45:07 UTC, Edwin van Leeuwen wrote: On Saturday, 17 September 2016 at 11:22:04 UTC, John Colvin wrote: On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote: How do I draw math formulas programmatically? I want to do on screen what latex does on

Re: Draw math formulas with ggplotd

2016-09-17 Thread John Colvin via Digitalmars-d-learn
On Saturday, 17 September 2016 at 02:41:15 UTC, brocolis wrote: How do I draw math formulas programmatically? I want to do on screen what latex does on .pdf. And I want to draw a math formula in the image generated with ggplotd. Generate data from those formulas (I like to do this with

Re: Compile Tango for DMD2 - Any instructions how to do it?

2016-05-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 12:24:06 UTC, TheDGuy wrote: On Wednesday, 18 May 2016 at 03:15:25 UTC, Mike Parker wrote: That should get your library. Thanks for your answer. I tried that on my windows console and i got the error that the command 'dub' can't be found.

Re: opDispatch and UFCS

2016-05-11 Thread John Colvin via Digitalmars-d-learn
On Thursday, 12 May 2016 at 00:04:43 UTC, Adam D. Ruppe wrote: On Wednesday, 11 May 2016 at 23:46:48 UTC, John Colvin wrote: Bug? Or am I misunderstanding how these two features are supposed to interact? I'm not sure what you actually expected there, but I'd note that in general, opDispatch

opDispatch and UFCS

2016-05-11 Thread John Colvin via Digitalmars-d-learn
struct S { int a; template opDispatch(string s) { template opDispatch(T...) { auto ref opDispatch(Args ...)(auto ref Args args) { return S(mixin(`a.` ~ s ~ (T.length ? `!T` : ``) ~ `(args)`)); } } } }

Re: Chaining opIndex

2016-05-09 Thread John Colvin via Digitalmars-d-learn
On Monday, 9 May 2016 at 20:14:25 UTC, deed wrote: struct Foo { Bars bars; ... } struct Foos { Foo[] arr; Foo opIndex (size_t idx) { return arr[idx]; } ... } struct Bar { // No Car[] cars; ... } struct Bars { Bar[] arr; Bar opIndex (size_t idx) { return

Re: No aa.byKey.length?

2016-04-04 Thread John Colvin via Digitalmars-d-learn
On Monday, 4 April 2016 at 02:32:56 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 00:50:27 UTC, Jonathan M Davis wrote: On Sunday, April 03, 2016 23:46:10 John Colvin via Digitalmars-d-learn wrote: On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote: > [...] Ma

Re: No aa.byKey.length?

2016-04-03 Thread John Colvin via Digitalmars-d-learn
On Saturday, 2 April 2016 at 16:00:51 UTC, Jonathan M Davis wrote: On Saturday, April 02, 2016 15:38:30 Ozan via Digitalmars-d-learn wrote: On Friday, 1 April 2016 at 20:50:32 UTC, Yuxuan Shui wrote: > Why? > > This is annoying when I need to feed it into a function that > requires hasLength.

Re: Is D a good choice for embedding python/octave/julia

2016-03-15 Thread John Colvin via Digitalmars-d-learn
On Sunday, 13 March 2016 at 13:02:16 UTC, Bastien wrote: Hi, apologies for what may be a fairly obvious question to some. ## The background: I have been tasked with building software to process data output by scientific instruments for non-experts - basically with GUI, menus, easy config

Re: RAII and classes

2016-03-09 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 9 March 2016 at 10:48:30 UTC, cym13 wrote: On Wednesday, 9 March 2016 at 10:28:06 UTC, John Colvin wrote: Potential for leaking references from alias this aside, is there some reason that I shouldn't do this for all my C++-like RAII needs: class A { ~this(){ import

RAII and classes

2016-03-09 Thread John Colvin via Digitalmars-d-learn
Potential for leaking references from alias this aside, is there some reason that I shouldn't do this for all my C++-like RAII needs: class A { ~this(){ import std.stdio; writeln("hello"); } } auto RAII(T)() if (is(T == class)) { struct Inner { private

Re: Calling python code from D

2016-02-26 Thread John Colvin via Digitalmars-d-learn
On Friday, 26 February 2016 at 17:15:02 UTC, Wyatt wrote: On Thursday, 25 February 2016 at 22:28:52 UTC, jmh530 wrote: I think PyD is really your best option. That's what I figured, but I wanted to be sure because, well... http://pyd.readthedocs.org/en/latest/embed.html ...these are some

Re: Installing DUB on OSX

2016-02-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 18 February 2016 at 23:28:43 UTC, Joel wrote: On Thursday, 18 February 2016 at 16:33:51 UTC, John Colvin wrote: [...] I don't think I put 'sudo brew' at any point (I can't remember). I hope I haven't broken my OSX! [...] Did you recently upgrade OS X? Anyway, you should

Re: Installing DUB on OSX

2016-02-18 Thread John Colvin via Digitalmars-d-learn
On Thursday, 18 February 2016 at 07:52:11 UTC, Joel wrote: On Thursday, 18 February 2016 at 07:11:23 UTC, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the problem, but where do you put it (also I tried one place, but couldn't put

Re: Procedural drawing using ndslice

2016-02-11 Thread John Colvin via Digitalmars-d-learn
On Thursday, 11 February 2016 at 13:05:41 UTC, Claude wrote: Hello, I come from the C world and try to do some procedural terrain generation, and I thought ndslice would help me to make things look clean, but I'm very new to those semantics and I need help. Here's my problem: I have a

Re: noob in c macro preprocessor hell converting gsl library header files

2016-01-06 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 6 January 2016 at 13:36:03 UTC, data pulverizer wrote: I have been converting C numeric libraries and depositing them here: https://github.com/dataPulverizer. So far I have glpk and nlopt converted on a like for like c function basics. I am now stuck on the gsl library, primarily

Re: immutable promise broken in unions?

2016-01-02 Thread John Colvin via Digitalmars-d-learn
On Saturday, 2 January 2016 at 10:04:47 UTC, Shriramana Sharma wrote: import std.stdio; union EarthLocation { struct { immutable double lon, lat, alt; } double[3] data; } void main() { EarthLocation d = {data: [4, 5, 6]}; writeln(d.data); d.data = [1, 2, 3];

Re: immutable promise broken in unions?

2016-01-02 Thread John Colvin via Digitalmars-d-learn
On Saturday, 2 January 2016 at 12:08:48 UTC, Meta wrote: On Saturday, 2 January 2016 at 12:07:31 UTC, John Colvin wrote: You are manually breaking immutable by making a union of immutable and mutable data and then writing to the mutable reference. This is roughly equivalent to casting away

Re: Why isn't field-wise constructor automatic for structs and not classes?

2016-01-02 Thread John Colvin via Digitalmars-d-learn
On Saturday, 2 January 2016 at 02:12:19 UTC, Shriramana Sharma wrote: If I have: struct TimeSpan { double start, end; } Then both the following automatically work: auto s = TimeSpan(); auto t = TimeSpan(1, 2); But if I make it a class (I need to) then I have to explicitly define a

Re: Why isn't field-wise constructor automatic for structs and not classes?

2016-01-02 Thread John Colvin via Digitalmars-d-learn
On Saturday, 2 January 2016 at 14:57:58 UTC, Shriramana Sharma wrote: John Colvin wrote: Strictly speaking you aren't calling a constructor there, you're writing a struct literal. Why do you say I'm not calling a constructor? https://dlang.org/spec/struct.html#struct-literal And that

Re: Segfault while compiling simple program

2015-12-16 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 16 December 2015 at 10:15:49 UTC, Saurabh Das wrote: 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

Re: I Did It! Calling D Library from Objective C in XCode on OSX

2015-12-16 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 16 December 2015 at 07:46:53 UTC, Jacob Carlborg wrote: On 2015-12-15 15:43, John Colvin wrote: I have no idea how you got something in /Library/D, but it doubt it was from homebrew. The native installer installs into /Library/D. Well that probably explains the problem then.

Re: Segfault while compiling simple program

2015-12-16 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 16 December 2015 at 09:26:33 UTC, 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) === dmd dprob.d Segmentation fault:

Re: I Did It! Calling D Library from Objective C in XCode on OSX

2015-12-14 Thread John Colvin via Digitalmars-d-learn
On Monday, 14 December 2015 at 11:12:03 UTC, Ali Çehreli wrote: On 12/14/2015 02:09 AM, Mike McKee wrote: I finally managed to get it working Congratulations! But this is not the right medium for this blog post. ;) Please polish and publish it somewhere before someone puts it on Reddit now.

Re: static array crashes my program

2015-12-05 Thread John Colvin via Digitalmars-d-learn
On Saturday, 5 December 2015 at 09:49:06 UTC, ref2401 wrote: I want to create a static array large enough to store 1MB of float values. What am I doing wrong? Here is a sample code with notes: void main(string[] args) { enum size_t COUNT = 1024 * 512 / float.sizeof; // works OK :)

Re: Exit with code xx

2015-11-25 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 25 November 2015 at 16:11:09 UTC, Ozan wrote: Hi Is there any overview, list, wiki about what's behind runtime errors like "Program exited with code -11"? Okay, I made a mistake...but it's better to know where and what kind? Thanks & Regards, Ozan That's just normal

Re: Is it a bug?

2015-11-25 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 25 November 2015 at 08:10:03 UTC, Jack Applegame wrote: This doesn't compile: import std.range; import std.algorithm; void main() { char[64] arr; copy(chain("test1", "test2"), arr[0..10]); } http://dpaste.dzfl.pl/24230ac02e6e Essentially this comes down to the

Re: dataframe implementations

2015-11-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:33:06 UTC, Jay Norwood wrote: On Wednesday, 18 November 2015 at 22:46:01 UTC, jmh530 wrote: My sense is that any data frame implementation should try to build on the work that's being done with n-dimensional slices. I've been watching that development, but

Re: Arty of Constructor

2015-11-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:20:28 UTC, Andrew wrote: The documentation gives plenty of examples of how to use a static if with the arity trait, but how do I specify the constructor of an object as the parameter to arity? Thanks Ugly but works: import std.traits; struct A {

Re: Unable to call each on a lockstep range containing 2 or more ranges

2015-11-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 18 November 2015 at 14:11:45 UTC, maik klein wrote: On Wednesday, 18 November 2015 at 13:51:59 UTC, John Colvin wrote: On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote: [...] I think this is a bug, please report it at issues.dlang.org and perhaps there will be

Re: Unable to call each on a lockstep range containing 2 or more ranges

2015-11-18 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 18 November 2015 at 12:20:42 UTC, maik klein wrote: https://stackoverflow.com/questions/33779822/unable-to-call-each-on-a-lockstep-range-containing-2-or-more-ranges http://dpaste.dzfl.pl/76c79f1f12ab void main(){ import std.container; import std.stdio; import

Re: Compiler doesn't complain with multiple definitions

2015-11-12 Thread John Colvin via Digitalmars-d-learn
On Thursday, 12 November 2015 at 15:06:26 UTC, ric maicle wrote: On Thursday, 12 November, 2015 07:50 PM, anonymous wrote: __traits has special syntax. The first "argument" must be from a list of special keywords that only have special meaning in that place. You can't put the name of a struct

Re: Capturing __FILE__ and __LINE in a variadic templated function

2015-11-02 Thread John Colvin via Digitalmars-d-learn
On Monday, 2 November 2015 at 09:16:09 UTC, Nordlöw wrote: On Monday, 2 November 2015 at 09:02:28 UTC, Gary Willoughby wrote: On Monday, 2 November 2015 at 08:23:16 UTC, Nordlöw wrote: I need `T` to be an alias in order for .stringof to work. typeof(T).stringof No, I want the variable name

Re: `clear`ing a dynamic array

2015-10-24 Thread John Colvin via Digitalmars-d-learn
On Saturday, 24 October 2015 at 13:18:26 UTC, Shriramana Sharma wrote: Hello. I had first expected that dynamic arrays (slices) would provide a `.clear()` method but they don't seem to. Obviously I can always effectively clear an array by assigning an empty array to it, but this has unwanted

Re: Mixin template parameter that is an undefined variable

2015-10-23 Thread John Colvin via Digitalmars-d-learn
On Friday, 23 October 2015 at 12:22:49 UTC, tcak wrote: [code] mixin template Test(alias a){ int a; } void main(){ mixin Test!blah; } [/code] Compiler says it doesn't know about "blah". My purpose is to define the parameter as a variable. Is that possible? you would have to

Re: Using C's fread/fwrite with File objects

2015-10-22 Thread John Colvin via Digitalmars-d-learn
On Thursday, 22 October 2015 at 18:20:07 UTC, pineapple wrote: I'd like to use fread and fwrite in place of File.rawRead and File.rawWrite which force the creation of an array where I'd rather specify a buffer location and length. D's arrays *are* just buffer locations and lengths with a few

Re: Allowing arbitrary types for a function's argument and return type

2015-10-22 Thread John Colvin via Digitalmars-d-learn
On Thursday, 22 October 2015 at 13:53:33 UTC, pineapple wrote: I'm just starting to hammer D's very pleasant syntax into my head. After "Hello world", the first thing I do when learning any language is to write a simple program which generates and outputs the Collatz sequence for an arbitrary

Re: Allowing arbitrary types for a function's argument and return type

2015-10-22 Thread John Colvin via Digitalmars-d-learn
On Thursday, 22 October 2015 at 15:10:58 UTC, pineapple wrote: On Thursday, 22 October 2015 at 14:36:52 UTC, John Colvin wrote: Using ranges instead of threads or fibers, slightly over-engineered to show off features: What does if(isIntegral!T) do? It looks like it would verify that the

Re: D serialization temporary fixup?

2015-10-22 Thread John Colvin via Digitalmars-d-learn
On Thursday, 22 October 2015 at 16:15:23 UTC, Shriramana Sharma wrote: I wanted a D equivalent to: http://doc.qt.io/qt-5/qdatastream.html https://docs.python.org/3/library/pickle.html and saw that one is under construction: http://wiki.dlang.org/Review/std.serialization But till it's

Re: Overloading an imported function

2015-10-21 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 21 October 2015 at 12:05:27 UTC, Shriramana Sharma wrote: import std.math; real round(real val, int prec) { real pow = 10 ^^ prec; return round(val * pow) / pow; } Trying to compile this I get: foo.d(5): Error: function foo.round (real val, int prec) is not callable

Re: Just one time

2015-10-20 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 15:48:47 UTC, Andrea Fontana wrote: It happens I need to perform an operation just one time (inside a function, a loop...) I wonder if doing this it's a good idea or not. bool isFirstTime(alias T)() { static val = true; if (val) {

Re: Just one time

2015-10-20 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 16:01:58 UTC, Andrea Fontana wrote: On Tuesday, 20 October 2015 at 15:55:47 UTC, John Colvin wrote: Be aware that there will be one instance of val per thread, so you are detecting the first run in each thread, not in the program overall. This is the kind of

Re: Idiomatic adjacent_difference

2015-10-16 Thread John Colvin via Digitalmars-d-learn
On Friday, 16 October 2015 at 11:11:28 UTC, Guillaume Chatelet wrote: Is there an idiomatic way to do: int[] numbers = [0, 1, 2, 3]; assert(adjacent_diff(numbers) == [1, 1, 1]); I can't find something useful in the std library. import std.range, std.algorithm; auto slidingWindow(R)(R r,

Re: Idiomatic adjacent_difference

2015-10-16 Thread John Colvin via Digitalmars-d-learn
On Friday, 16 October 2015 at 12:03:56 UTC, Per Nordlöw wrote: On Friday, 16 October 2015 at 11:48:19 UTC, Edwin van Leeuwen wrote: zip(r, r[1..$]).map!((t) => t[1]-t[0]); And for InputRanges (not requiring random-access): zip(r, r.dropOne).map!((t) => t[1]-t[0]); We should have a good

Re: Frequent cannot deduce function from argument types

2015-10-16 Thread John Colvin via Digitalmars-d-learn
On Friday, 16 October 2015 at 15:48:59 UTC, Edwin van Leeuwen wrote: Just wondering if anyone has any tips on how to solve/avoid "cannot deduce function from argument types" when relying on template programming. I run into these problems all the time. Current one was when I tried: ``` auto

Re: Frequent cannot deduce function from argument types

2015-10-16 Thread John Colvin via Digitalmars-d-learn
On Friday, 16 October 2015 at 15:48:59 UTC, Edwin van Leeuwen wrote: Just wondering if anyone has any tips on how to solve/avoid "cannot deduce function from argument types" when relying on template programming. I run into these problems all the time. Current one was when I tried: ``` auto

Re: Why isn't global operator overloading allowed in D?

2015-10-15 Thread John Colvin via Digitalmars-d-learn
On Thursday, 15 October 2015 at 15:45:00 UTC, Shriramana Sharma wrote: John Colvin wrote: On Wednesday, 14 October 2015 at 15:02:02 UTC, Shriramana Sharma wrote: What binary arithmetic operators do you need that real[] doesn't already support? OMG silly me! I can already do a[] /= b[]...

Re: OT: why do people use python when it is slow?

2015-10-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 14:32:00 UTC, jmh530 wrote: On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote: https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow Andrei suggested posting more widely. I was just writing some R code yesterday after playing

Re: Why isn't global operator overloading allowed in D?

2015-10-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 15:02:02 UTC, Shriramana Sharma wrote: Hello. I just came upon a need in my program to make binary arithmetic operators valid between two real[] in my programs What binary arithmetic operators do you need that real[] doesn't already support?

Re: OT: why do people use python when it is slow?

2015-10-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 October 2015 at 15:25:22 UTC, David DeWitt wrote: On Wednesday, 14 October 2015 at 14:48:22 UTC, John Colvin wrote: On Wednesday, 14 October 2015 at 14:32:00 UTC, jmh530 wrote: On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote:

Re: Regarding std.array.Appender

2015-10-13 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:21:54 UTC, Suliman wrote: I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)' I suspect you don't have it imported. import std.algorithm; or import std.algorithm :

Re: Array of BitArrays definition compiles in DMD but not in GDC.

2015-10-09 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 21:40:02 UTC, TheGag96 wrote: In my code I'm passing an array of BitArrays to a constructor like this (though mostly as a placeholder): Terrain t = new Terrain(1, 15, [ BitArray([1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), BitArray([1, 1, 1, 1, 1, 0, 1, 1,

Re: Check template parameter whether it has "length"

2015-10-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote: I am "trying" to write a function that takes an array of items, and returns the length of longest item. [code] size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, "length" ) ) { return 0; // not

Re: Check template parameter whether it has "length"

2015-10-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 October 2015 at 15:22:02 UTC, tcak wrote: BTW, there is nothing like std.traits.hasLength. yeah, that's because __traits(hasMember, ...) should be good enough, but obviously not in this case at the moment.

Re: Online Phobos Prerelease Docs

2015-10-05 Thread John Colvin via Digitalmars-d-learn
On Monday, 5 October 2015 at 08:19:26 UTC, Per Nordlöw wrote: Is there an (official or unoffical) prerelease version of the Phobos docs, typically for studying std.allocator? It would be nice to have the D servers auto-generate this every time a PR is merged into druntime/phobos.

Re: Online Phobos Prerelease Docs

2015-10-05 Thread John Colvin via Digitalmars-d-learn
On Monday, 5 October 2015 at 09:53:09 UTC, Per Nordlöw wrote: On Monday, 5 October 2015 at 08:45:54 UTC, John Colvin wrote: http://dlang.org/phobos/index.html it's on the sidebar I can't find allocator there (yet) in tree. http://dlang.org/phobos-prerelease/std_experimental_allocator.html

Re: std.functional:partial - disambiguating templated functions

2015-10-04 Thread John Colvin via Digitalmars-d-learn
On Sunday, 4 October 2015 at 15:45:55 UTC, Laeeth Isharc wrote: How do I persuade partial to tie itself to the appropriate overload? I have: alias bars=partial!(slurpBars!BarType,filename,startDate,endDate); where there are two overloads of slurpBars: SomeBar[] slurpBars(SomeBar)(string

Re: std.functional:partial - disambiguating templated functions

2015-10-04 Thread John Colvin via Digitalmars-d-learn
On Sunday, 4 October 2015 at 19:12:51 UTC, Laeeth Isharc wrote: On Sunday, 4 October 2015 at 18:24:08 UTC, John Colvin wrote: On Sunday, 4 October 2015 at 18:08:55 UTC, Laeeth Isharc wrote: On Sunday, 4 October 2015 at 17:17:14 UTC, Laeeth Isharc wrote: On Sunday, 4 October 2015 at 16:37:34

Re: std.functional:partial - disambiguating templated functions

2015-10-04 Thread John Colvin via Digitalmars-d-learn
On Sunday, 4 October 2015 at 20:26:51 UTC, John Colvin wrote: template bish(T) { alias tmp = bish0!T; alias tmp = bish1!T; alias bish = tmp; } https://issues.dlang.org/show_bug.cgi?id=15156

Re: std.functional:partial - disambiguating templated functions

2015-10-04 Thread John Colvin via Digitalmars-d-learn
On Sunday, 4 October 2015 at 18:08:55 UTC, Laeeth Isharc wrote: On Sunday, 4 October 2015 at 17:17:14 UTC, Laeeth Isharc wrote: On Sunday, 4 October 2015 at 16:37:34 UTC, John Colvin wrote: On Sunday, 4 October 2015 at 15:45:55 UTC, Laeeth Isharc wrote: How do I persuade partial to tie itself

Re: Linker error with dmd

2015-10-02 Thread John Colvin via Digitalmars-d-learn
On Friday, 2 October 2015 at 09:43:54 UTC, Chris wrote: Why do I get this error msg with dmd 2.067.1 and 2.068.0 in release mode: $ dub --build=release (.data._D65TypeInfo_xC3std5range10interfaces18__T10InputRangeTiZ10InputRange6__initZ+0x10): undefined reference to

Re: Checking that a template parameter is an enum

2015-10-02 Thread John Colvin via Digitalmars-d-learn
On Friday, 2 October 2015 at 08:13:00 UTC, John Colvin wrote: On Thursday, 1 October 2015 at 22:26:39 UTC, Nordlöw wrote: On Thursday, 1 October 2015 at 02:06:48 UTC, Fusxfaranto wrote: [...] Thanks! BTW: Is there some way to turn the recursive definition of `allSame` template

Re: Checking that a template parameter is an enum

2015-10-02 Thread John Colvin via Digitalmars-d-learn
On Thursday, 1 October 2015 at 22:26:39 UTC, Nordlöw wrote: On Thursday, 1 October 2015 at 02:06:48 UTC, Fusxfaranto wrote: /** Returns: true iff all values $(D V) are the same. */ template allSame(V...) // TODO restrict to values only { static if (V.length <= 1) enum

Re: WTF does "Enforcement failed" actually mean?

2015-10-01 Thread John Colvin via Digitalmars-d-learn
On Thursday, 1 October 2015 at 07:08:00 UTC, Russel Winder wrote: On Wed, 2015-09-30 at 23:35 -0700, Ali Çehreli via Digitalmars-d-learn wrote: On 09/30/2015 10:46 PM, Russel Winder via Digitalmars-d-learn wrote: > [...] It's coming from the following no-message enforce():

  1   2   3   4   5   6   >