std.concurrency and immutable

2013-11-24 Thread Antoche
The following code compiles but doesn't work as expected: import std.stdio; import std.concurrency; class A { this() immutable {} } void main() { auto tid = spawn( &fooBar, thisTid ); while(true) { receive(

Re: Cleverness of the compiler

2013-11-24 Thread Shammah Chancellor
On 2013-11-25 00:08:50 +, Namespace said: I love this feature, but I'm unsure how it works. Can someone explain me, how the compiler deduce that he should read 4 bytes for each index (the 'at' function)? The type is void*, not int*. It doesn't work. That code is buggy. It's overwriting

Re: Composing features at compile time

2013-11-24 Thread Shammah Chancellor
Based on what your actual problem is -- it seems like you need to refactor your code a little. Also, you should trust that the compiler optimizes correctly. eg. if( valueMeta.isValid && pointersSupported) should be optimized out when pointerSupported == false and the comparison of it shou

Re: Cleverness of the compiler

2013-11-24 Thread Namespace
I meant the function: void at(T)(ref Tarray arr, size_t index, T* elem) { if (index >= arr.length || elem is null) return; memcpy(elem, &arr.ptr[index], T.sizeof); } -> arr.ptr[index]

Re: Cleverness of the compiler

2013-11-24 Thread growler
On Monday, 25 November 2013 at 00:51:47 UTC, growler wrote: On Monday, 25 November 2013 at 00:08:52 UTC, Namespace wrote: I love this feature, but I'm unsure how it works. Can someone explain me, how the compiler deduce that he should read 4 bytes for each index (the 'at' function)? The type is

Re: Cleverness of the compiler

2013-11-24 Thread growler
On Monday, 25 November 2013 at 00:08:52 UTC, Namespace wrote: I love this feature, but I'm unsure how it works. Can someone explain me, how the compiler deduce that he should read 4 bytes for each index (the 'at' function)? The type is void*, not int*. import std.stdio; import core.stdc.s

Cleverness of the compiler

2013-11-24 Thread Namespace
I love this feature, but I'm unsure how it works. Can someone explain me, how the compiler deduce that he should read 4 bytes for each index (the 'at' function)? The type is void*, not int*. import std.stdio; import core.stdc.stdlib : calloc, realloc, free; import core.stdc.string : memcpy

Re: Composing features at compile time

2013-11-24 Thread Philippe Sigaud
On Sun, Nov 24, 2013 at 9:44 PM, Jacob Carlborg wrote: > On 2013-11-24 21:14, Philippe Sigaud wrote: > >> If features are coupled, I see no easy way out. > > > I suspected that. They not so much coupled with each other, rather coupled > with the default functionality that will always be there. I

Re: Composing features at compile time

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 21:14, Philippe Sigaud wrote: If features are coupled, I see no easy way out. I suspected that. They not so much coupled with each other, rather coupled with the default functionality that will always be there. If references are not supported, you want the else clause all by

Re: D scientific graphics

2013-11-24 Thread seany
*can't dman it

Re: Composing features at compile time

2013-11-24 Thread Philippe Sigaud
>Unfortunately this looks like it works best when providing fairly separate >features > that doesn't interact with each other or the main functionality. If features are coupled, I see no easy way out. > http://pastebin.com/XYGtTarn > > Lines 19-25, 34-37 and 42 are only needed if pointers are s

Re: Composing features at compile time

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 14:18, Jacob Carlborg wrote: Does anyone know a good way of composing features at compile time? Say I have a struct or class that I want to support different features that are configurable at compile time. One way would be to just pass in a couple of boolean flags and use static-if,

Re: Composing features at compile time

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 20:53, Philippe Sigaud wrote: Hmm. Then you still need to define where the policy will act. OK, I can get that. I thought the OP wanted something more flexible, where different loggers could inject code at many different places. But if there is no Logging policy asked for (the use

Re: Composing features at compile time

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 19:28, Dejan Lekic wrote: Jakob, whenever I need something like you describe, I do more/less the same what is described on this Wikipedia page: http://en.wikipedia.org/wiki/Composition_over_inheritance . C# example is exactly how I do this (in Java and D). Unfortunately this look

Re: Composing features at compile time

2013-11-24 Thread Dicebot
On Sunday, 24 November 2013 at 19:37:44 UTC, Jacob Carlborg wrote: So StubLogger would implement "info" but do nothing? How good would the compiler be at optimizing this? Last time I checked such stuff LDC is quite capable at eliminating it completely. It works somewhat better for state-less

Re: Composing features at compile time

2013-11-24 Thread Philippe Sigaud
On Sun, Nov 24, 2013 at 6:25 PM, Dicebot wrote: > On Sunday, 24 November 2013 at 14:23:55 UTC, Philippe Sigaud wrote: >> >> But how do you use policies to inject different code in different >> places of your struct? > > > Don't really get the question. Isn't it what policies do pretty much by > de

Re: Composing features at compile time

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 18:31, Dicebot wrote: To clarify, OP example will look like this: class Foo (alias Logger) if (isLoggger!Logger) { private Logger logger; this () { logger = new Logger; } void action () { logger.info("performing action

Re: DStep

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 16:02, Craig Dillabaugh wrote: So the following command works (at least on my system): dstep -I/usr/lib64/clang/3.2/include shapefil.h Thanks for your help. Great to hear. -- /Jacob Carlborg

Re: 64-bit builds fails

2013-11-24 Thread Jesse Phillips
On Saturday, 23 November 2013 at 08:15:31 UTC, evilrat wrote: Greetings, straight to the problem - latest release(2.064.2) has a nasty bug with distribution. official installer missing Runtime.initialize() and Runtime.terminate() symbols in phobos.lib for x64 version. i tried to use rt_init(

Re: Composing features at compile time

2013-11-24 Thread Dejan Lekic
Jacob Carlborg wrote: > Does anyone know a good way of composing features at compile time? Say I > have a struct or class that I want to support different features that > are configurable at compile time. One way would be to just pass in a > couple of boolean flags and use static-if, like this: >

Re: undefined reference to `_D16TypeInfo_HAyayAa6__initZ'

2013-11-24 Thread Adam D. Ruppe
On Sunday, 24 November 2013 at 12:07:18 UTC, Dejan Lekic wrote: Adam, does it support multiplexing? Looks like people do not care much about that FastCGI feature... :( I don't really know, I just wrote the loop similar to the libfcgi example and left it at that. So probably not, unless the c l

Re: Composing features at compile time

2013-11-24 Thread Dicebot
On Sunday, 24 November 2013 at 17:25:49 UTC, Dicebot wrote: Don't really get the question. Isn't it what policies do pretty much by definition? You decompose part of target functionality into smaller blocks with optional behavior (including no-op behavior) and provide specific ones as alias par

Re: Composing features at compile time

2013-11-24 Thread Dicebot
On Sunday, 24 November 2013 at 14:23:55 UTC, Philippe Sigaud wrote: But how do you use policies to inject different code in different places of your struct? Don't really get the question. Isn't it what policies do pretty much by definition? You decompose part of target functionality into sma

Re: regex in tango.text.Util.containsPattern

2013-11-24 Thread seany
ah! thank you soo much

Re: DStep

2013-11-24 Thread Craig Dillabaugh
On Sunday, 24 November 2013 at 14:04:32 UTC, Jacob Carlborg wrote: On 2013-11-24 14:58, Craig Dillabaugh wrote: I have clang installed on my machine. Is there anyway to point dstep to the right headers when I invoke it? Yes, use the -I flag. In addition to the listed flags, DStep accept al

Re: DStep

2013-11-24 Thread Craig Dillabaugh
On Sunday, 24 November 2013 at 13:01:15 UTC, Gary Willoughby wrote: On Friday, 22 November 2013 at 14:35:45 UTC, Craig Dillabaugh wrote: I am trying to use DStep on OpenSuse 12.3. I downloaded one of the binaries (it was for Debian, so I guess that is my problem), and when I run DStep I get t

Re: Composing features at compile time

2013-11-24 Thread Philippe Sigaud
But how do you use policies to inject different code in different places of your struct? On Sun, Nov 24, 2013 at 3:15 PM, Dicebot wrote: > Well you can make one step forward and use policy-based design as described > in Andrei's old C++ book ;) (replace boolean flags with template aliases to > mi

Re: Composing features at compile time

2013-11-24 Thread Dicebot
Well you can make one step forward and use policy-based design as described in Andrei's old C++ book ;) (replace boolean flags with template aliases to mixin, providing stub ones for "false") It does not fix `static-if` sequence but scales better in terms of configurability.

Re: Composing features at compile time

2013-11-24 Thread Philippe Sigaud
> Unfortunately logging and events were more of an example, for the real usage Ah then, you can discard my own proposals. Only #3 is still possible. Try not to think to much of AST macros :-)

Re: Composing features at compile time

2013-11-24 Thread Philippe Sigaud
The general problem is to inject code at predetermined points. As Rémy said, that should remind us of AOP. I have three other very vague ideas ;-) Not tested in any way. #1) Create a wrapper, say Interceptor!(Foo, "__ctor", "bar"). Interceptor will act as a Foo, except it will have hooks that are

Re: Composing features at compile time

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 15:06, "Rémy Mouëza" wrote: This looks like a case study for aspect oriented programming: several separated concerns that start to intertwine within your code; if left unchecked this could result in some messy code. In Python, I used reflection and "magic" things and have already u

Re: Composing features at compile time

2013-11-24 Thread Rémy Mouëza
This looks like a case study for aspect oriented programming: several separated concerns that start to intertwine within your code; if left unchecked this could result in some messy code. In Python, I used reflection and "magic" things and have already used the spring AOP in Java that is done

Re: DStep

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 14:01, Gary Willoughby wrote: I ran into the same issue and the documentation does cover it, but why on earth should a binary require a header file? It needs the header files when compiling C code. Up until after phase of creating the AST I assume the process would be exactly th

Re: DStep

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 14:58, Craig Dillabaugh wrote: I have clang installed on my machine. Is there anyway to point dstep to the right headers when I invoke it? Yes, use the -I flag. In addition to the listed flags, DStep accept all flags Clang accepts. I already got Tango working - that was clea

Re: Calling D from C

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 08:22, evilrat wrote: ok i find out what's your problem. here is 2 ways of solving this problem. 1) build like you do already but add to gcc call phobos lib, so it will looks like "gcc bar.c foo.o /usr/share/dmd/lib/libphobos2.a" 2) build with foo.d with "dmd foo.d -lib" which ge

Re: DStep

2013-11-24 Thread Craig Dillabaugh
On Sunday, 24 November 2013 at 13:05:04 UTC, Jacob Carlborg wrote: On 2013-11-24 06:37, Craig Dillabaugh wrote: Thanks. That is how I started out trying to fix it (Well, I used symlinks rather than copy the files, but basically the same). I got it to stop complaining about stddef.h and stdar

Composing features at compile time

2013-11-24 Thread Jacob Carlborg
Does anyone know a good way of composing features at compile time? Say I have a struct or class that I want to support different features that are configurable at compile time. One way would be to just pass in a couple of boolean flags and use static-if, like this: class Foo (bool logging, boo

Re: undefined reference to `_D16TypeInfo_HAyayAa6__initZ'

2013-11-24 Thread Jeroen Bollen
On Sunday, 24 November 2013 at 12:07:18 UTC, Dejan Lekic wrote: On Saturday, 23 November 2013 at 23:47:11 UTC, Adam D. Ruppe wrote: On Saturday, 23 November 2013 at 23:30:09 UTC, Jeroen Bollen wrote: I added the code to my GitHub repo; there don't seem to be any uncommon associative arrays: Y

Re: DStep

2013-11-24 Thread Jacob Carlborg
On 2013-11-24 06:37, Craig Dillabaugh wrote: Thanks. That is how I started out trying to fix it (Well, I used symlinks rather than copy the files, but basically the same). I got it to stop complaining about stddef.h and stdarg.h, but at the third header (can't recall something obscure though)

Re: DStep

2013-11-24 Thread Gary Willoughby
On Friday, 22 November 2013 at 14:35:45 UTC, Craig Dillabaugh wrote: I am trying to use DStep on OpenSuse 12.3. I downloaded one of the binaries (it was for Debian, so I guess that is my problem), and when I run DStep I get the following error: craigkris@linux-s9qf:~/code/DShape/D> dstep shapef

Re: core.sys.posix.termios

2013-11-24 Thread Jacob Carlborg
On 2013-11-23 20:08, Ellery Newcomer wrote: is there any particular reason it is missing B115200 and friends? No, these files are usually ported when someone needs them. Just make a pull request and will most likely be merged quite easily. -- /Jacob Carlborg

Re: regex in tango.text.Util.containsPattern

2013-11-24 Thread Jacob Carlborg
On 2013-11-22 21:03, seany wrote: How do i find strings in form of X... (in regex: X{Y*} using tango.text.Util.containsPattern ? the documentation does not mention regex. So i have a string where multiple substrngs in the format X{Y*} can appear, and I would like to identify all of them, it

Re: undefined reference to `_D16TypeInfo_HAyayAa6__initZ'

2013-11-24 Thread Dejan Lekic
On Saturday, 23 November 2013 at 23:47:11 UTC, Adam D. Ruppe wrote: On Saturday, 23 November 2013 at 23:30:09 UTC, Jeroen Bollen wrote: I added the code to my GitHub repo; there don't seem to be any uncommon associative arrays: Yea, it is the immutable string[string], I used the same pattern

Re: Calling D from C

2013-11-24 Thread CJS
On Sunday, 24 November 2013 at 07:22:37 UTC, evilrat wrote: On Sunday, 24 November 2013 at 05:25:36 UTC, CJS wrote: dmd -c foo.d gcc bar.c foo.o ok i find out what's your problem. here is 2 ways of solving this problem. 1) build like you do already but add to gcc call phobos lib, so it wi

Re: Read Byte Array to Integer

2013-11-24 Thread Ali Çehreli
On 11/22/2013 02:55 PM, Jeroen Bollen wrote:> On Friday, 22 November 2013 at 21:17:56 UTC, monarch_dodra wrote: >> On Friday, 22 November 2013 at 19:44:56 UTC, Jeroen Bollen wrote: >>> On Friday, 22 November 2013 at 19:22:16 UTC, Ali Çehreli wrote: import std.bitmanip; import std.system

Re: Read Byte Array to Integer

2013-11-24 Thread Jeroen Bollen
On Friday, 22 November 2013 at 21:17:56 UTC, monarch_dodra wrote: On Friday, 22 November 2013 at 19:44:56 UTC, Jeroen Bollen wrote: On Friday, 22 November 2013 at 19:22:16 UTC, Ali Çehreli wrote: import std.bitmanip; import std.system; void main() { ubyte[] data = [ 1, 2, 3, 4 ]; assert(da

Re: Calling D from C

2013-11-24 Thread evilrat
On Sunday, 24 November 2013 at 06:48:50 UTC, Jesse Phillips wrote: On Sunday, 24 November 2013 at 05:54:44 UTC, evilrat wrote: On Sunday, 24 November 2013 at 05:25:36 UTC, CJS wrote: bash calls: dmd -c foo.d gcc bar.c foo.o this is wrong. there should flag for building static lib which sho

Re: Calling D from C

2013-11-24 Thread evilrat
On Sunday, 24 November 2013 at 05:25:36 UTC, CJS wrote: dmd -c foo.d gcc bar.c foo.o ok i find out what's your problem. here is 2 ways of solving this problem. 1) build like you do already but add to gcc call phobos lib, so it will looks like "gcc bar.c foo.o /usr/share/dmd/lib/libphobos2