Re: idup class

2014-05-16 Thread Joshua Niehus via Digitalmars-d-learn
On Friday, 16 May 2014 at 20:36:37 UTC, Ali Çehreli wrote: My apologies. The code was written for an older version of dmd. The simplest fix is to define the constructor as pure: pure this(int num) { this.num = num; } Ali Ahh great thanks guys. No worries Ali, great book,

idup class

2014-05-16 Thread Joshua Niehus via Digitalmars-d-learn
trying to follow: http://ddili.org/ders/d.en/class.html //--- OSX 10.9 DMD 2.065 module test; class Foo { int num; this(int num) { this.num = num; } Foo dup() const { return new Foo(this.num); } immutable(Foo) idup() const { return new

Re: core.sync.rwmutex example

2014-05-09 Thread Joshua Niehus via Digitalmars-d-learn
Hi Charles, would the following work (just a shot in the dark) ? //--- module test; import std.stdio; import std.concurrency; void spawnedFuncFoo(Tid tid, Tid tidBar) { receive( (int i) { writeln("Foo Received the number ", i); send(tidBar, i, thisTid);

Atom text editor

2014-05-06 Thread Joshua Niehus via Digitalmars-d-learn
FYI: If anyone is using GitHub's text editor "Atom" and would like basic D syntax highlighting: apm init --package ~/.atom/packages/language-d --convert https://github.com/textmate/d.tmbundle https://atom.io/docs/v0.94.0/converting-a-text-mate-bundle

Re: fedora libcurl-gnutls issue

2013-09-27 Thread Joshua Niehus
On Friday, 27 September 2013 at 16:52:49 UTC, Dicebot wrote: Simply building dmd/phobos from git tag should result in proper linkage. Nothing is ever simple with me :) Thanks Dejan and Dicebot

fedora libcurl-gnutls issue

2013-09-27 Thread Joshua Niehus
http://d.puremagic.com/issues/show_bug.cgi?id=10710 Does anyone know if there is there a workaround for this issue? Unfortunately Im stuck with fedora and cant jump to another OS... Thanks

Re: shared std.signals

2013-01-22 Thread Joshua Niehus
On Wednesday, 23 January 2013 at 07:11:59 UTC, Joshua Niehus wrote: Is it possible to create a shared signal class? oh god... dont tell me __gshared ! Think i answered my own question, it got me to the next step. going to have to read through those giant "shared" threads again

shared std.signals

2013-01-22 Thread Joshua Niehus
Is it possible to create a shared signal class? I would like to create a shared signal class so some other process that knows certain things can come along emit its info to any observer: import std.stdio, std.signals; class Observer { void watch(string msg) { writeln(msg); }

Re: Help me write "saveAll"

2012-12-21 Thread Joshua Niehus
On Friday, 21 December 2012 at 17:01:14 UTC, monarch_dodra wrote: There are a lot of algorithms in std.algorithm that operate on "foo(Range, Needles...)(Range range, Needles needles)". Needles can be anything, in particular, either an "element" or a "range". The thing is that every now and t

Re: prune with dirEntries

2012-11-30 Thread Joshua Niehus
On Friday, 30 November 2012 at 19:52:26 UTC, Jonathan M Davis wrote: If you're compiling with -property, filter must have the parens for the function call as it's a function, not a property. The !() is for the template arguments and is separate from the parens for the function call. That means

Re: prune with dirEntries

2012-11-30 Thread Joshua Niehus
On Friday, 30 November 2012 at 12:02:51 UTC, Dan wrote: Good idea, thanks. I could not get original to compile as is - but the concept is just what was needed. I got an error on line 8: Error: not a property dirEntries(path, cast(SpanMode)0, true).filter!(__lambda2) I'm using a quite recent ve

Re: prune with dirEntries

2012-11-29 Thread Joshua Niehus
On Friday, 30 November 2012 at 06:29:01 UTC, Joshua Niehus wrote: I think if you go breadth first, you can filter out the unwanted directories before it delves into them oh wait... it probably still looks through all those dir's. What about this? import std.algorithm, std.regex, std.

Re: prune with dirEntries

2012-11-29 Thread Joshua Niehus
On Friday, 30 November 2012 at 01:57:21 UTC, Dan wrote: That will do the filtering correctly - but what I was hoping was to actually prune at the directory level and not drill down to the files in of an unwanted directory (e.g. .git). The problem with this and what I'm trying to overcome is acc

Re: path matching problem

2012-11-27 Thread Joshua Niehus
On Tuesday, 27 November 2012 at 23:43:43 UTC, Charles Hixson wrote: But why the chained filters, rather than using the option provided by dirEntries for one of them? Is it faster? Just the way you usually do things? (Which I accept as a legitimate answer. I can see that that approach would b

Re: path matching problem

2012-11-27 Thread Joshua Niehus
On Tuesday, 27 November 2012 at 19:40:56 UTC, Charles Hixson wrote: Is there a better way to do this? (I want to find files that match any of some extensions and don't match any of several other strings, or are not in some directories.): import std.file; ... string exts = "*.{txt,utf8,

Re: Converting a number to complex

2012-11-25 Thread Joshua Niehus
On Saturday, 24 November 2012 at 07:27:18 UTC, Philippe Sigaud wrote: It's an is() expression (you cited my tutorial, there is an appendix on it). It recently became even more powerful, so the tutorial is not accurate any more. its time for another read through:) Template constraints might ma

Re: Converting a number to complex

2012-11-23 Thread Joshua Niehus
On Friday, 23 November 2012 at 18:45:53 UTC, Artur Skawina wrote: template isComplex(T) { static if (is(T _ == Complex!CT, CT)) enum isComplex = true; else enum isComplex = false; } artur oh wow didnt know u could do that. much nicer.

Re: Converting a number to complex

2012-11-23 Thread Joshua Niehus
meh, couldn't resist: import std.stdio, std.conv, std.traits, std.complex; template isComplex(T) { static if (is(T == Complex!double)) { enum bool isComplex = true; } else static if (is(T == Complex!float)) { enum bool isComplex = true; } else static if

Re: Converting a number to complex

2012-11-23 Thread Joshua Niehus
On Friday, 23 November 2012 at 16:11:25 UTC, Joshua Niehus wrote: A bit messy, but im sure there is some room for cleanup somewhere... Errata... (what i get for copy/pasting) import std.stdio, std.conv, std.traits, std.complex; template isComplexNumeric(T) { static if(isNumeric!T

Re: Converting a number to complex

2012-11-23 Thread Joshua Niehus
On Friday, 23 November 2012 at 12:39:59 UTC, Frederik Vagner wrote: Now do it for complex number please ^^ touche! import std.stdio, std.conv, std.traits, std.complex; template isComplexNumeric(T) { static if(is(NumericTypeOf!T)) { enum bool isComplexNumeric = is(NumericTypeOf!T);

Re: Converting a number to complex

2012-11-22 Thread Joshua Niehus
On Thursday, 22 November 2012 at 15:47:11 UTC, Frederik Vagner wrote: I am trying to make a templated class to accept any numeric type: class example(Type) if (isNumeric(Type)) { Type k = to!Type(1); } however I always get a compiler erro stating I cannot make that conversion. Ho

parallelism with message passing

2012-11-20 Thread Joshua Niehus
Hello, Im starting one process in the main thread who in turn is going to kick off another process but has no way of passing along main's Tid, hence the shared(Tid) nonsense. * This works in serial (i.e. change workUnitSize > x.length in mains foreach loop). * It also works when passing the tid

Re: std.concurrency msg passing

2012-10-18 Thread Joshua Niehus
On Thursday, 18 October 2012 at 17:33:04 UTC, cal wrote: I can't see the bug? The receiver accepts a bool as an int, same way a normal function does. The timeout is long enough that foo gets a chance to send. If you want to stop the int receiver getting a bool, you could add another receiver w

std.concurrency msg passing

2012-10-17 Thread Joshua Niehus
Is the following snippet a bug? --- import core.thread; import std.stdio, std.concurrency; void foo(Tid tid) { send(tid, true); } void main() { auto fooTid = spawn(&foo, thisTid); auto receiveInt = receiveTimeout(dur!"seconds"(10), (int isInt) { writeln("I should not be he

Re: -lib question(s)

2012-04-29 Thread Joshua Niehus
On Monday, 30 April 2012 at 02:49:21 UTC, Jesse Phillips wrote: However you also will need to specify the library you want to load: -L-lworld More detail. [snip] Hi Jesse, Thanks for the help, that was informative! I didn't realize I needed the load command (-L-lworld) and so I was trying t

-lib question(s)

2012-04-27 Thread Joshua Niehus
Hello, I have a few methods that I want to put into a library but I'm having some trouble figuring out how to go about doing it... Here is my "library": // world.d module world; import std.traits; T hello(T)(T name) /* probably want a string constraint here... */ { return "hello " ~ name;

Re: regex issue

2012-03-16 Thread Joshua Niehus
On Friday, 16 March 2012 at 08:34:18 UTC, Dmitry Olshansky wrote: Ehm, because they have different engines that _should_ give identical results. And the default one apparently has a bug, that I'm looking into. Fill the bug report plz. Ok, submitted: id 7718 Thanks, Josh

regex issue

2012-03-15 Thread Joshua Niehus
Hello, Does anyone know why I would get different results between ctRegex and regex in the following snippet? Thanks, Josh --- #!/usr/local/bin/rdmd import std.stdio, std.regex; void main() { string strcmd = "./myApp.rb -os OSX -path \"/GIT/Ruby Apps/sec\" -conf 'no timer'"; auto ctre

Re: Compiling DMD on MAC OS X

2012-02-29 Thread Joshua Niehus
Hi Andrew, I ran into this problem as well and here is how I fixed/hacked it: OSX Lion, and soon to be Mountain Lion, no longer come with GCC installed for the Command Line (/usr/bin/gcc) What you need to do is Install Xcode from the app store, which is free, and then: * Launch your Xcode

Re: Compiling DMD on MAC OS X

2012-02-29 Thread Joshua Niehus
On Monday, 20 February 2012 at 11:18:34 UTC, Tyro[a.c.edwards] wrote: ... and I doubt you want me to put all of what "dmd -v" spits out for this little script. Thanks, Andrew Hi Andrew, I ran into this problem as well and here is how I fixed/hacked it: OSX Lion, and soon to be Mountain Lio

Re: Reflection

2012-02-27 Thread Joshua Niehus
On Tuesday, 28 February 2012 at 06:10:11 UTC, Jesse Phillips wrote: It is a template. I see, thanks. And I bet its not possible to figure out if a template is a "function template" or a "class template" etc...

Reflection

2012-02-27 Thread Joshua Niehus
Hello, I dont understand the following snippet's output: import std.stdio, std.traits; void main() { writeln(isSomeFunction!(writeln)); writeln(isCallable!(writeln)); writeln("Yes I am..."); } /* OUTPUT */ false false Yes I am... If 'writeln' isn't a method/function and it's not ca

Syntax highlighting for CodeRunner

2012-02-26 Thread Joshua Niehus
In the off chance that some of you are running a Mac and using CodeRunner to play around with D, I cooked up the files you need for CodeRunner to highlight D's syntax: https://github.com/jniehus/Dlang-for-CodeRunner

Waiting around

2012-01-09 Thread Joshua Niehus
Hello, I need to connect to a network location and read a file but I also need some way of waiting around until the connection is established. Currently I use the following snippet to do this: while (!std.file.exists("/Volumes/mountedDir/myfile.txt") && timeout < 30) { core.thread.Thread

Re: File append Limit

2011-08-05 Thread Joshua Niehus
@Kagamin > What if > > foreach(i;0..512) { > append("/Users/dirList.txt", text("line ",i,'\n')); > } That works, but I misrepresented the problem and found that the following may be the issue (this looks more like the code im using): import std.conv, std.stdio; void main() { string[] strAr

File append limit?

2011-08-05 Thread Joshua Niehus
Hello, I am running a script that creates a file which lists all the folders in a directory: foreach (string name; dirEntries("/Users/josh/", SpanMode.shallow)) { append("/Users/dirList.txt", name ~ "\n"); } But it seems to stop appending after 255 lines (this particular folder h

Interfacing to C

2011-06-28 Thread Joshua Niehus
Hello, I was trying to run the example on the Interfacing to C page ( http://www.d-programming-language.org/interfaceToC.html) and ran into few issues. To get it to work "as is" i was .dup(ing) strings into new chars with defined size and passing those with .ptr. Anyway it seemed like quite a bit

RE: dmdscript osx.mak

2011-06-19 Thread Joshua Niehus
Hi Robert and Dmitry, Thanks for your replies and the heads up on the current status of DMDScript! Josh

dmdscript osx.mak

2011-06-17 Thread Joshua Niehus
Hello, I apologize if this is the wrong forum to post this question, but I couldn't find a corresponding learn mailing list for DMDScript. I wanted to play around with DMDScript but cant seem to get started. I downloaded the source and attempted to make it via: $ make -f osx.mak But I get t

Re: simple syntax issue with template

2011-06-13 Thread Joshua Niehus
> I'm trying to create 2 extra method for arrays ("range" would be > better, though I don't quite understand what is a "range") > Although I have some indecipherable (to me) compiler error... > > What's wrong with the code below? > == > import std.algorithm; > > public: > > void rem

Re: dmd vs rdmd

2011-06-13 Thread Joshua Niehus
t; > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Digitalmars-d-learn digest..." > > > Today's Topics: > > 1. dmd vs rdmd (Joshua Niehus) > 2. Re: dmd vs rdmd (Jonathan M Davis) > 3. Re: dmd vs rdmd

dmd vs rdmd

2011-06-10 Thread Joshua Niehus
Hello, I am trying to compile code which is composed of two modules (in the same directory): main.d foo.d foo.d just declares a class Foo which has a string variable "bar" which i set to "hello" and main.d just prints bar's value to the console: // - main.d --- import std.stdio,