how to avoid cycle detected?

2015-07-01 Thread aki via Digitalmars-d-learn
Following code causes run-time error. How can I use static this() without causing error? It's difficult to avoid this situation because actual code is more complex. file main.d: void main() { } file a.d: import b; class A { static this() {} }; file b.d: import a; class B {

Re: Mutable reference to const objects

2015-07-01 Thread Yuxuan Shui via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 08:30:23 UTC, Yuxuan Shui wrote: How do I express a mutable reference to a const object in D? What I want to do is to define a variable, which refers a constant object, but I can change which constant object it is referring. Is this possible? I wonder will

Mutable reference to const objects

2015-07-01 Thread Yuxuan Shui via Digitalmars-d-learn
How do I express a mutable reference to a const object in D? What I want to do is to define a variable, which refers a constant object, but I can change which constant object it is referring. Is this possible?

Re: Mutable reference to const objects

2015-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 08:33:44 UTC, Yuxuan Shui wrote: On Wednesday, 1 July 2015 at 08:30:23 UTC, Yuxuan Shui wrote: How do I express a mutable reference to a const object in D? What I want to do is to define a variable, which refers a constant object, but I can change which constant

Re: Nullable with reference types

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 30, 2015 14:29:52 Steven Schveighoffer via Digitalmars-d-learn wrote: I know this is just back-of-envelope, but what's wrong with: alias Nullable(T) if(is(T == class)) = T; bool isNull(T)(T t) if(is(T == class)) { return t is null;} In principle, there's no reason why we

Re: tkd - basic compilation problem

2015-07-01 Thread Jordi Sayol via Digitalmars-d-learn
El 30/06/15 a les 16:28, Paul via Digitalmars-d-learn ha escrit: Using dub I get this during linking: Building tkd-test ~master configuration application, build type debug. Compiling using dmd... Linking... /usr/bin/ld: cannot find -ltcl /usr/bin/ld: cannot find -ltk ...any suggestions

Re: goroutines vs vibe.d tasks

2015-07-01 Thread Mathias Lang via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: Just creating a bunch (10k) of sleeping (for 100 msecs) goroutines/tasks. Compilers go: go version go1.4.2 linux/amd64 vibe.d: DMD64 D Compiler v2.067.1 linux/amd64, vibe.d 0.7.23 Code go: http://pastebin.com/2zBnGBpt

Re: Same process to different results?

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 1:44 PM, Steven Schveighoffer wrote: Schizophrenia of Phobos. Phobos thinks a string is a range of dchar instead of a range of char. So what cycle, take, and array all output are dchar ranges and arrays. When you cast the dchar[] result to a string, (which is a char[]), it then

Re: Template Declarations - Why not Template definitions?

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 09:29:56 via Digitalmars-d-learn wrote: On Tuesday, 30 June 2015 at 21:06:58 UTC, WhatMeWorry wrote: Bonus question: Isn't a Zero-parameter template declaration pretty much worthless? Functions in templates get certain attributes inferred automatically, like

Re: how to avoid cycle detected?

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 5:09 AM, aki wrote: Following code causes run-time error. How can I use static this() without causing error? It's difficult to avoid this situation because actual code is more complex. file main.d: void main() { } file a.d: import b; class A { static this() {} }; file b.d:

Re: Adam Ruppe's COM library - calling COM object from dynamic code eg VBA

2015-07-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 05:47:44 UTC, Laeeth Isharc wrote: The COM object isn't recognised by dynamic languages such as Python and VBA, even after registering. You use the regsvr32 program to do it?

Re: std.concurrent Tid vector initialization problem

2015-07-01 Thread via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 19:19:43 UTC, Charles Hixson wrote: On Sunday, 28 June 2015 at 09:59:29 UTC, Marc Schütz wrote: On Sunday, 28 June 2015 at 01:02:02 UTC, Charles Hixson wrote: I'm planning an application where a series of threads each ...gn. Does anyone have a better idea? (The

Re: tkd - basic compilation problem

2015-07-01 Thread via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 07:37:48 UTC, Paul wrote: On Tuesday, 30 June 2015 at 16:06:41 UTC, Marc Schütz wrote: On Tuesday, 30 June 2015 at 15:25:27 UTC, Alex Parrill wrote: On Tuesday, 30 June 2015 at 14:28:49 UTC, Paul wrote: Using dub I get this during linking: Building tkd-test

Re: Adam Ruppe's COM library - calling COM object from dynamic code eg VBA

2015-07-01 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 09:32:23 UTC, Kagamin wrote: I did it only for javascript, it doesn't need type library. First thing to do is to check whether registration succeeded. I prefer to register to HKCR for testing purposes. fix HKCU

Re: Adam Ruppe's COM library - calling COM object from dynamic code eg VBA

2015-07-01 Thread Kagamin via Digitalmars-d-learn
I did it only for javascript, it doesn't need type library. First thing to do is to check whether registration succeeded. I prefer to register to HKCR for testing purposes.

Re: how to avoid cycle detected?

2015-07-01 Thread ketmar via Digitalmars-d-learn
On Wed, 01 Jul 2015 09:09:52 +, aki wrote: Following code causes run-time error. How can I use static this() without causing error? you currently can't, sorry. signature.asc Description: PGP signature

Re: Static constructors guaranteed to run?

2015-07-01 Thread via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 07:55:20 UTC, ketmar wrote: On Mon, 29 Jun 2015 17:22:17 +, Marc Schütz wrote: On Monday, 29 June 2015 at 11:36:42 UTC, ketmar wrote: it doesn't, afair, but it's quite natural. if user type was throwed out as unused, it would be very strange to insist on

Re: Array operations, dynamic arrays and length

2015-07-01 Thread via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 22:37:34 UTC, ixid wrote: int[] a = [1,1,1,1]; int[] b = [1,1,1,1]; int[] c; c[] = a[] - b[]; c.writeln; This outputs []. This feels wrong, it feels like something that should have exploded or set the length to 4. If the

Re: Nullable with reference types

2015-07-01 Thread via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 18:29:31 UTC, Steven Schveighoffer wrote: I know this is just back-of-envelope, but what's wrong with: alias Nullable(T) if(is(T == class)) = T; bool isNull(T)(T t) if(is(T == class)) { return t is null;} That's what I intended. (Same for pointers and slices,

Re: how to avoid cycle detected?

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 09:09:52 aki via Digitalmars-d-learn wrote: Following code causes run-time error. How can I use static this() without causing error? It's difficult to avoid this situation because actual code is more complex. file main.d: void main() { } file a.d: import b;

Concurrency in DLL

2015-07-01 Thread Chris via Digitalmars-d-learn
Would anyone know off the top of the head why a std.concurrency.send() message can fail in a DLL? The DLL is loaded into Python and works (including the threading) when in a test program or mine and loaded via cytpes.CDLL() etc. However, embedded in a third party package, where it is loaded

Re: Nullable with reference types

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 5:45 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Tuesday, 30 June 2015 at 18:29:31 UTC, Steven Schveighoffer wrote: I know this is just back-of-envelope, but what's wrong with: alias Nullable(T) if(is(T == class)) = T; bool isNull(T)(T t) if(is(T == class)) { return

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 09:38:05 UTC, Marc Schütz wrote: Someone more familiar with Debian/Ubuntu than me may be able to help you here, sorry. I was hoping to keep a tight rein on what was required to be installed to simplify deployment but its spiraling out of control again LOL. The

Re: Nullable with reference types

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 5:45 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Tuesday, 30 June 2015 at 18:29:31 UTC, Steven Schveighoffer wrote: I know this is just back-of-envelope, but what's wrong with: alias Nullable(T) if(is(T == class)) = T; bool isNull(T)(T t) if(is(T == class)) { return

Re: Pure delegate not quite pure?

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/15 9:29 PM, Tofu Ninja wrote: On Wednesday, 1 July 2015 at 00:13:36 UTC, Jesse Phillips wrote: On Tuesday, 30 June 2015 at 22:23:40 UTC, Tofu Ninja wrote: On Tuesday, 30 June 2015 at 22:05:43 UTC, Steven Schveighoffer wrote: Have you tried placing const on the function signature?

Re: Best way to count character spaces.

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 1:25 AM, H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Jun 30, 2015 at 06:33:32PM +, Taylor Hillegeist via Digitalmars-d-learn wrote: So I am aware that Unicode is not simple... I have been working on a boxes like project http://boxes.thomasjensen.com/ it basically puts a

Re: Template Declarations - Why not Template definitions?

2015-07-01 Thread via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 21:06:58 UTC, WhatMeWorry wrote: Bonus question: Isn't a Zero-parameter template declaration pretty much worthless? Functions in templates get certain attributes inferred automatically, like `@nogc`, `pure`, `nothrow`, `@safe`. Some people use them for that

Re: Static constructors guaranteed to run?

2015-07-01 Thread ketmar via Digitalmars-d-learn
On Wed, 01 Jul 2015 09:42:31 +, Marc Schütz wrote: The behaviour you expect makes more sense, for sure, but I was trying to guess what the current implementation might be doing without actually having to try it :-) ah, sorry. i was talking about the ideal case with ideal compiler, not

Re: Multi-dimensional fixed arrays

2015-07-01 Thread DLearner via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 22:04:24 UTC, Justin Whear wrote: alias IntList = int[10]; IntList[3] myIntLists; int[10][3] myOtherIntLists; // same type as above I understand the rationale, but some issues: 1. The rationale implicitly takes treats an n-dim array as a (n-1)-dim array x

Re: Adam Ruppe's COM library - calling COM object from dynamic code eg VBA

2015-07-01 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 13:43:08 UTC, Adam D. Ruppe wrote: On Wednesday, 1 July 2015 at 05:47:44 UTC, Laeeth Isharc wrote: The COM object isn't recognised by dynamic languages such as Python and VBA, even after registering. You use the regsvr32 program to do it? Yes...

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:43:11 UTC, Gary Willoughby wrote: On Tuesday, 30 June 2015 at 12:58:21 UTC, Paul wrote: ... I really don't understand posts like this when literally all information needed is in the README file: https://github.com/nomad-software/tkd Just read RTFM. I read

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 18:38:27 UTC, Jordi Sayol wrote: For shared linking against libphobos2.so and libtkd.so: $ dmd `pkg-config --cflags --libs tkd` -J/usr/share/libtkd-doc/example/media/ /usr/share/libtkd-doc/example/example.d For static linking against libphobos2.a and libtkd.a: $

Re: goroutines vs vibe.d tasks

2015-07-01 Thread rsw0x via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 18:09:19 UTC, Mathias Lang wrote: On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: [...] In your dub.json, can you use the following: subConfigurations: { vibe-d: libasync }, dependencies: { vibe-d: ~0.7.24-beta.3 },

Re: wrong struct alignment

2015-07-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 20:01:08 UTC, dd0s wrote: intscope_id; // 4 short port; // 8 // -- this is 4 bytes instead of 2 That's expected because scope_id takes 4 bytes, so port has to be at 8 so it doesn't overlap the preceding int. The extra two bytes you see in sizeof

wrong struct alignment

2015-07-01 Thread dd0s via Digitalmars-d-learn
i have the following struct, and i expect it to have 30 bytes but sizeof tells me it has 32 bytes. dmd seems to still use 4byte alignment altough i specified to align 2bytes. struct netadr_t { align(2): inttype; // 0 intscope_id; // 4 short port; // 8 // -- this is

Re: wrong struct alignment

2015-07-01 Thread anonymous via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 20:01:08 UTC, dd0s wrote: i have the following struct, and i expect it to have 30 bytes but sizeof tells me it has 32 bytes. dmd seems to still use 4byte alignment altough i specified to align 2bytes. struct netadr_t { align(2): inttype; // 0

Re: Array operations, dynamic arrays and length

2015-07-01 Thread Alex Parrill via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 22:37:34 UTC, ixid wrote: int[] a = [1,1,1,1]; int[] b = [1,1,1,1]; int[] c; c[] = a[] - b[]; c.writeln; This outputs []. This feels wrong, it feels like something that should have exploded or set the length to 4. If the

Re: Nullable with reference types

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 08:43:59 Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/1/15 5:45 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Tuesday, 30 June 2015 at 18:29:31 UTC, Steven Schveighoffer wrote: I know this is just back-of-envelope, but what's wrong with:

Re: Pure delegate not quite pure?

2015-07-01 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 12:34:35 UTC, Steven Schveighoffer wrote: immutable is probably incorrect without a cast, since immutable cannot be applied implicitly to non-immutable data, and if the data is all immutable already, no sense in tagging it immutable. I really see use in allowing

Re: Array operations, dynamic arrays and length

2015-07-01 Thread via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 19:09:36 UTC, Alex Parrill wrote: I don't think this is a bug. Since you don't initialize `c` to anything, it defaults to an empty slice. Array [] operations apply to each element of a slice, but `c` doesn't have any elements, so it does nothing. I _do_ think

Re: wrong struct alignment

2015-07-01 Thread dd0s via Digitalmars-d-learn
thank you both, indeed missed that truncation step

Re: Same process to different results?

2015-07-01 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 01, 2015 at 02:14:49PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/1/15 1:44 PM, Steven Schveighoffer wrote: Schizophrenia of Phobos. Phobos thinks a string is a range of dchar instead of a range of char. So what cycle, take, and array all output are dchar

Same process to different results?

2015-07-01 Thread Taylor Hillegeist via Digitalmars-d-learn
When I run the code (compiled on DMD 2.067.1): -- import std.algorithm; import std.stdio; import std.range; string A=AaA; string B=BbBb; string C=CcCcC; void main(){ int L=25; int seg1len=(L-B.length)/2; int seg2len=B.length;

Re: Same process to different results?

2015-07-01 Thread Taylor Hillegeist via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:06:01 UTC, Adam D. Ruppe wrote: I betcha it is because A, B, and C are modified by the first pass. A lot of the range functions consume their input. Running them one at a time produces the same result. for some reason: (A.cycle.take(seg1len).array

Re: Same process to different results?

2015-07-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/1/15 1:00 PM, Taylor Hillegeist wrote: When I run the code (compiled on DMD 2.067.1): -- import std.algorithm; import std.stdio; import std.range; string A=AaA; string B=BbBb; string C=CcCcC; void main(){ int L=25; int

Re: Same process to different results?

2015-07-01 Thread anonymous via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:13:03 UTC, Taylor Hillegeist wrote: string q = cast(string) (A.cycle.take(seg1len).array ~B.cycle.take(seg2len).array ~C.cycle.take(seg3len).array); q.writeln; I was wondering if it might be the cast? Yes, the cast is wrong. You're reinterpreting (not

Re: tkd - basic compilation problem

2015-07-01 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 12:58:21 UTC, Paul wrote: ... I really don't understand posts like this when literally all information needed is in the README file: https://github.com/nomad-software/tkd Just read RTFM.

Re: Same process to different results?

2015-07-01 Thread Taylor Hillegeist via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:00:51 UTC, Taylor Hillegeist wrote: When I run the code (compiled on DMD 2.067.1): -- import std.algorithm; import std.stdio; import std.range; string A=AaA; string B=BbBb; string C=CcCcC; void main(){

Re: tkd - basic compilation problem

2015-07-01 Thread Paul via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 16:06:41 UTC, Marc Schütz wrote: On Tuesday, 30 June 2015 at 15:25:27 UTC, Alex Parrill wrote: On Tuesday, 30 June 2015 at 14:28:49 UTC, Paul wrote: Using dub I get this during linking: Building tkd-test ~master configuration application, build type debug.

Re: Packing enums

2015-07-01 Thread ketmar via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:05:47 UTC, qznc wrote: Something like this: enum X { A, B, C }; enum Y { foo, bar, baz }; alias both = TwoEnums!(X,Y); static assert(both.sizeof == 1); both z; z.X = B; z.Y = bar; that's so easy that it's not even funny... enum X { A, B, C }; enum Y { foo, bar,

Re: is it safe to call `GC.removeRange` in dtor?

2015-07-01 Thread ketmar via Digitalmars-d-learn
thank you both. then i think that it should be explicitly stated in core.memory.

Re: goroutines vs vibe.d tasks

2015-07-01 Thread Daniel Kozák via Digitalmars-d-learn
Same problem still extreamly slow On Wed, 01 Jul 2015 03:28:01 + rsw0x anonym...@anonymous.com wrote: On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: Just creating a bunch (10k) of sleeping (for 100 msecs) goroutines/tasks. Compilers go: go version go1.4.2

Re: Static constructors guaranteed to run?

2015-07-01 Thread ketmar via Digitalmars-d-learn
On Mon, 29 Jun 2015 17:22:17 +, Marc Schütz wrote: On Monday, 29 June 2015 at 11:36:42 UTC, ketmar wrote: it doesn't, afair, but it's quite natural. if user type was throwed out as unused, it would be very strange to insist on keeping it's initialization code. Yes, but I would instead

etc.c.zlib help

2015-07-01 Thread Matthew Gamble via Digitalmars-d-learn
I am trying to make the transition from C++ to D. I've hit a snag with the etc.c.zlib module where any attempt to use this module to open a file yields an error: Error 42: Symbol Undefined __lseeki64. Here is a simple example of code that gives the error upon compilation. import std.stdio;

Re: how to avoid cycle detected?

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 08:52:38 Steven Schveighoffer via Digitalmars-d-learn wrote: The runtime cannot introspect the code to detect the circular dependency, so it makes a conservative decision. I'm waiting on an introduction of RTInfo for modules [1] to allow us to mark static ctors as

Re: proper way to calculate toHash() for string

2015-07-01 Thread aki via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 19:36:24 UTC, Jacob Carlborg wrote: On 30/06/15 16:19, aki wrote: Please suggest me if anyone have an idea. You can use TypeInfo.getHash [1] to get the hash of a given value. Something like: string a = foo; typeid(a).getHash(a) [1]

Re: Array operations, dynamic arrays and length

2015-07-01 Thread J Miller via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 21:15:13 UTC, Marc Schütz wrote: On Wednesday, 1 July 2015 at 19:09:36 UTC, Alex Parrill wrote: I don't think this is a bug. Since you don't initialize `c` to anything, it defaults to an empty slice. Array [] operations apply to each element of a slice, but `c`