Re: Why doesn't this have a length?

2012-03-13 Thread Magnus Lie Hetland
this issue then covers both (despite the different error messages)? I'll just leave this alone (i.e., not submit any additional tickets), then (and cast away the constness for now; seems to help). -- Magnus Lie Hetland http://hetland.org

Re: Sorting char arrays

2012-03-13 Thread Magnus Lie Hetland
On 2012-03-12 17:33:35 +, Ali Çehreli said: You can use isNarrowString to either disallow or provide special implementation for narrow strings (char[] and wchar[]): Ah -- useful, thanks! -- Magnus Lie Hetland http://hetland.org

Re: Why doesn't this have a length?

2012-03-13 Thread Magnus Lie Hetland
On 2012-03-13 14:24:37 +, H. S. Teoh said: Indeed. Would've thought const AA keys would be reasonable. (In Python they're *required*... :) [...] I'm of the opinion that AA keys should be *implicitly* immutable. Seconded, whole-heartedly. -- Magnus Lie Hetland http://hetland.org

Sorting char arrays

2012-03-12 Thread Magnus Lie Hetland
) in the Bugzilla. (No biggie for me, though; the Phobos sort seems to fail with all kinds of things, so I have my own anyway... ;) -- Magnus Lie Hetland http://hetland.org

Re: Tempfiles in unittests

2012-03-12 Thread Magnus Lie Hetland
;-) But no problem -- not many lines to add to my own code. -- Magnus Lie Hetland http://hetland.org

Re: Sorting char arrays

2012-03-12 Thread Magnus Lie Hetland
On 2012-03-12 13:56:15 +, bearophile said: It's not a bug, char is meant to be a UTF-8. Right. Two workarounds: Thanks. I'm doing the sorting in a template, so this won't work -- but I guess I just can't use char as a type parameter to my template either, then :) -- Magnus Lie

Why doesn't this have a length?

2012-03-12 Thread Magnus Lie Hetland
?-) -- Magnus Lie Hetland http://hetland.org

Re: Tempfiles in unittests

2012-03-11 Thread Magnus Lie Hetland
surprised me that there wasn't a standard way of writing file-related unit tests :) -- Magnus Lie Hetland http://hetland.org

Re: Tempfiles in unittests

2012-03-10 Thread Magnus Lie Hetland
tempfiles don't seem to have names (i.e., they are unnamed tempfiles, and file.name is null; platform-dependent, I think). Otherwise, this wouldn't have been a problem :) -- Magnus Lie Hetland http://hetland.org

Tempfiles in unittests

2012-03-09 Thread Magnus Lie Hetland
, rather than file-like objects, i.e., those with the appropriate methods...) -- Magnus Lie Hetland http://hetland.org

Re: Tempfiles in unittests

2012-03-09 Thread Magnus Lie Hetland
On 2012-03-09 15:08:42 +, bearophile said: Magnus Lie Hetland: It seems that File has no method for reading the entire file contents into a string, so I'd have to read and concatenate lines or chunks or something? There are std.file.read() and std.file.readText(). Yeah, I found those

Re: Should uniform(-real.max, real.max) be inf?

2012-03-02 Thread Magnus Lie Hetland
behavior? Perhaps it's been left out for a reason? (Sounds sort of likely ;-) -- Magnus Lie Hetland http://hetland.org

Getting the mutable version of a type

2012-03-02 Thread Magnus Lie Hetland
like that? (E.g., a template in Phobos or something.) I guess I could do a match with an is() expression to extract the type, perhaps. -- Magnus Lie Hetland http://hetland.org

Re: Getting the mutable version of a type

2012-03-02 Thread Magnus Lie Hetland
On 2012-03-02 11:23:20 +, Ali Çehreli said: On 03/02/2012 02:18 AM, Magnus Lie Hetland wrote: I'm writing a template for generating data of some possibly immutable type -- e.g., a string. What I'm wondering is, is there some way of accessing the mutable version of an immutable type? Yes

Should uniform(-real.max, real.max) be inf?

2012-03-01 Thread Magnus Lie Hetland
terribly helpful. What's the standard thing to do here? I could just use uniform(cast(T) -1, cast(T) 1)*T.max I guess (for some floating-point type T). Seems to work fine, at least. Am I missing the obvious way to do it? -- Magnus Lie Hetland http://hetland.org

Re: Should uniform(-real.max, real.max) be inf?

2012-03-01 Thread Magnus Lie Hetland
On 2012-03-01 10:52:49 +, Magnus Lie Hetland said: I could just use uniform(cast(T) -1, cast(T) 1)*T.max I guess (for some floating-point type T). Seems to work fine, at least. Aaactually, not so much. The output here seems to get about the same exponent as T.max. Which isn't all

Re: More general Cartesian product

2012-02-29 Thread Magnus Lie Hetland
) { static if (lvl == args.length) { func(args); } else { foreach (e; args[lvl]) { forall!(func, lvl+1) (args[0..lvl], e, args[lvl+1..$]); } } } -- Magnus Lie Hetland http://hetland.org

Re: DbC bug?

2012-02-27 Thread Magnus Lie Hetland
method(uint arg) in { // assert(arg + 1); // Uncomment to prevent bug } out { assert(arg == 0, BUG: arg == ~ to!string(arg)); } body {} } void main(string[] args) { (new Class).method(0); } -- Magnus Lie Hetland http://hetland.org

DbC bug?

2012-02-23 Thread Magnus Lie Hetland
I think I've stumbled across a DbC bug. In an out-block, I have the assertion `assert(id objs.length);`. Now, if I don't have an in-block, this fails. However, if I add an in-block (with basically any code that isn't optimized away, or so it seems), the assertion succeeds. (Before this was an

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-04 Thread Magnus Lie Hetland
different repos...? Do I have to assemble a full distro myself, or am I just missing something obvious? (I'm assuming the latter, really ;) -- Magnus Lie Hetland http://hetland.org

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-04 Thread Magnus Lie Hetland
On 2011-08-04 12:27:54 +, Alex Rønne Petersen said: Hi, You can see my blog for Linux: http://xtzgzorex.wordpress.com/2011/07/31/d-building-dmd-and-phobos-on-linux/ Thanks! -- Magnus Lie Hetland http://hetland.org

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-04 Thread Magnus Lie Hetland
... SDK=/Developer/SDKs/MacOSX10.5.sdk #SDK=/Developer/SDKs/MacOSX10.6.sdk ... into ... SDK=/Developer/SDKs/MacOSX10.5.sdk #SDK=/Developer/SDKs/MacOSX10.6.sdk SDK=/Developer/SDKs/MacOSX10.7.sdk (or equivalent). -- Magnus Lie Hetland http://hetland.org

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-04 Thread Magnus Lie Hetland
. (It can be useful to have the most recent version; ideally, it should have fewer bugs ;) If that fails, I could try just the runtime, as you suggest. -- Magnus Lie Hetland http://hetland.org

GG bug? (OS X Lion, DMD 2.054)

2011-08-03 Thread Magnus Lie Hetland
the collector is a bit over-eager...? -- Magnus Lie Hetland http://hetland.org

Re: GG bug? (OS X Lion, DMD 2.054)

2011-08-03 Thread Magnus Lie Hetland
, probably Lion-related, bugs in my test suite...) -- Magnus Lie Hetland http://hetland.org

Re: Polymorphism problem w/local functions?

2011-07-20 Thread Magnus Lie Hetland
forgetting, other than type-based switch statements?) Thanks, - M -- Magnus Lie Hetland http://hetland.org

Polymorphism problem w/local functions?

2011-07-18 Thread Magnus Lie Hetland
at least one of the local functions (but not if you, for example, comment out the global ones, of course). Is this a bug, or am I just missing the reasoning behind it? Any workarounds? (I'm still at 2.052, so maybe this works in the new version?) -- Magnus Lie Hetland http://hetland.org

Else clauses for loops

2011-04-13 Thread Magnus Lie Hetland
that the feature has been requested a few years ago [1], so there might not be that much demand for this sort of thing. Is there perhaps a D idiom here already? [1] http://d.puremagic.com/issues/show_bug.cgi?id=2304 -- Magnus Lie Hetland http://hetland.org

Re: Before and after in contracts?

2011-04-13 Thread Magnus Lie Hetland
on this that I could add my vote to? If not, perhaps it's worth creating one? If not, I guess I could just post a bump to the D group :-} -- Magnus Lie Hetland http://hetland.org

Before and after in contracts?

2011-04-11 Thread Magnus Lie Hetland
this? If not, can it be done in a less ugly manner? (Or should I just learn to like this way of doing it?) -- Magnus Lie Hetland http://hetland.org

Re: Before and after in contracts?

2011-04-11 Thread Magnus Lie Hetland
be local to one specific in/out instantiation (or stack frame) would be preferable. I guess I could just use a local variable (guarded by version()) and then have an assert() near the end of the function. Probably a better solution... -- Magnus Lie Hetland http://hetland.org

Can I use a delegate as a template parameter? (Issue 2962?)

2011-03-30 Thread Magnus Lie Hetland
, generally seems to do so), but it might be a bit problematic? This way of doing it seems like the most practical for my current use, though... (I.e., I'd like foo to be inline-able, and have access to x.) -- Magnus Lie Hetland http://hetland.org

How do you use BinaryHeap with Array (or just make a growable heap)?

2011-03-28 Thread Magnus Lie Hetland
question: 3. How do you (canonically) make a growable heap using Phobos? -- Magnus Lie Hetland http://hetland.org

Re: How do you use BinaryHeap with Array (or just make a growable heap)?

2011-03-28 Thread Magnus Lie Hetland
it in a PriorityQueue class, which takes care of resizing the array (and having BinaryHeap switch to the possibly reallocated new one). Not an ideal solution, but at least it works. -- Magnus Lie Hetland http://hetland.org

Bug in tuple comparison?

2011-03-24 Thread Magnus Lie Hetland
from argument types !()(const(Tuple!(real,uint))) I take it this is a bug (or am I just missing something)? Is it a known bug? (Sorry if it's in the tracker; it can be hard to find equivalents there...) -- Magnus Lie Hetland http://hetland.org

Re: Bug in tuple comparison?

2011-03-24 Thread Magnus Lie Hetland
On 2011-03-24 18:25:30 +0100, bearophile said: Magnus Lie Hetland: I guess this is getting old by now ... but I've come across yet another bug :- The out(result) turns the result into a const, Riiight! Yes, I've seen that it's const, and (naughtily) cast away the constness (without

Re: Bug w/tuple of custom types?

2011-03-23 Thread Magnus Lie Hetland
used an uint that was of a semantically different kind, and got a hard-to-spot bug -- so I thought I'd try to prevent that by using the type system. Any way to do that without (to be deprecated) typedef? -- Magnus Lie Hetland http://hetland.org

Bug w/tuple of custom types?

2011-03-21 Thread Magnus Lie Hetland
it there already.) -- Magnus Lie Hetland http://hetland.org

Re: Deducing types for function templates

2011-03-21 Thread Magnus Lie Hetland
inferencebug.foo(T) cannot deduce template function from argument types !()(uint[],real function(uint x, uint y)) -- Magnus Lie Hetland http://hetland.org

Deducing types for function templates

2011-03-15 Thread Magnus Lie Hetland
to have a template so I could just do Foo!T foo(T)(T[] bar, baz_t!T baz) { ... } However, I haven't been able to define such a template without running into the same problem (i.e., that DMD no longer can deduce what T should be from my arguments). Any pointers? -- Magnus Lie Hetland http

Re: Semi-const methods?

2011-03-14 Thread Magnus Lie Hetland
with it: http://stackoverflow.com/questions/4219600/logical-const-in-d Thanks for the insights + tip :) -- Magnus Lie Hetland http://hetland.org

Re: Semi-const methods?

2011-03-14 Thread Magnus Lie Hetland
On 2011-03-14 11:51:09 +0100, Mafi said: I found away which doesn't use casts or bugs. Just use delegates/closures. Nice :D -- Magnus Lie Hetland http://hetland.org

foo.bar !in baz not allowed?

2011-03-13 Thread Magnus Lie Hetland
; Foo foo; auto res = (foo.bar) !in baz; res = !(foo.bar in baz); // res = foo.bar !in baz; // Not OK... uint frozz; res = frozz !in baz; } -- Magnus Lie Hetland http://hetland.org

Re: foo.bar !in baz not allowed?

2011-03-13 Thread Magnus Lie Hetland
On 2011-03-13 21:27:27 +0100, spir said: On 03/13/2011 07:58 PM, Magnus Lie Hetland wrote: For some reason, it seems like expressions of the form foo.bar !in baz aren't allowed. I suspect this is a grammar/parser problem -- the bang is interpreted as a template argument operator, rather than

Semi-const methods?

2011-03-13 Thread Magnus Lie Hetland
to local variables) early on in the relevant methods (dropping the const modifier on the method itself -- sort of a bummer). Any other ideas on how to handle this sort of mostly const or const where it counts stuff? Perhaps my design intentions here are off to begin with?-) -- Magnus Lie

Re: Semi-const methods?

2011-03-13 Thread Magnus Lie Hetland
On 2011-03-13 23:27:14 +0100, Magnus Lie Hetland said: Any other ideas on how to handle this sort of mostly const or const where it counts stuff? Perhaps my design intentions here are off to begin with?-) OK -- a *little* quick on the trigger there. My solution: Declare the method const

Re: Semi-const methods?

2011-03-13 Thread Magnus Lie Hetland
On 2011-03-13 23:32:34 +0100, Magnus Lie Hetland said: (Still open to schooling on the design part of this, though. Perhaps declaring a method as const is no good when it's not *really* const? For now, I'm just doing it to check that I don't inadvertently change things I don't want to change

Re: Iterating over 0..T.max

2011-03-10 Thread Magnus Lie Hetland
talking about a limit of 256... :D) And, for the record, I'm using DMD 2.052 (OS X). Just replace bool with byte in your program, and it should compile. Sorry for the brain fart ;) -- Magnus Lie Hetland http://hetland.org

Iterating over 0..T.max

2011-03-09 Thread Magnus Lie Hetland
and overflow checking, would it be possible to catch this special case (i.e., detect when the array can be too long for the index type)? Or are any other safeguards possible to prevent this sort of thing? -- Magnus Lie Hetland http://hetland.org

Re: Growable BinaryHeap: use w/Array?

2011-03-07 Thread Magnus Lie Hetland
On 2011-03-06 14:58:10 +0100, Magnus Lie Hetland said: [corrected the example below, replacing int with string] that works just fine. However, if I try alias Tuple!(real,string) Entry; Array!Entry Q; then I get the following errors: container.d(1549): Error: this for _data needs

Growable BinaryHeap: use w/Array?

2011-03-06 Thread Magnus Lie Hetland
, or appender instances, for that matter? Or, to put the questions a bit differently: Is there a reason why std.array doesn't have an insertBack method (that BinaryHeap can use) either defined for dynamic arrays or for std.array.Appender? Just trying to figure out what's what here :) -- Magnus Lie

std.gc doc page

2011-03-06 Thread Magnus Lie Hetland
. Also, there's no core.memory link in the sidebar...) -- Magnus Lie Hetland http://hetland.org

Re: Growable BinaryHeap: use w/Array?

2011-03-06 Thread Magnus Lie Hetland
On 2011-03-06 14:37:19 +0100, Magnus Lie Hetland said: Just wondering: If I want a growable binary heap (I'd be open to other priority queue structures, for that matter ;), is the standard way in D (w/Phobos) to combine std.container.BinaryHeap with std.container.Array? Another thing

Re: Growable BinaryHeap: use w/Array?

2011-03-06 Thread Magnus Lie Hetland
On 2011-03-06 15:00:29 +0100, David Nadlinger said: On 3/6/11 2:58 PM, Magnus Lie Hetland wrote: alias Tuple!(real,int) Entry; Array!Entry Q; [...] alias Tuple!(real,int) Entry; Array!Entry Q; Is it just me, or is there really no difference between the two snippets? ;) $(WITTY_REPLY

Re: Two questions about %a

2011-03-04 Thread Magnus Lie Hetland
be safe -- and perhaps more easily read on other platforms, for example (byte order), or into floats with other precisions or the like. Thanks for the suggestion, though :) -- Magnus Lie Hetland http://hetland.org

Overriding in operator

2011-03-04 Thread Magnus Lie Hetland
elsewhere in my code, preventing the operator overloading to take force. Suggestions/solutions?-) -- Magnus Lie Hetland http://hetland.org

Overriding iteration

2011-03-04 Thread Magnus Lie Hetland
foreach(e; foo[])? Is there no way to get this functionality directly (i.e., for foreach(e; foo))? -- Magnus Lie Hetland http://hetland.org

Re: Overriding in operator

2011-03-04 Thread Magnus Lie Hetland
reporting? Anwyay: Thanks for the clarification :) -- Magnus Lie Hetland http://hetland.org

Re: Overriding iteration

2011-03-04 Thread Magnus Lie Hetland
On 2011-03-04 17:46:39 +0100, Simen kjaeraas said: Simen kjaeraas simen.kja...@gmail.com wrote: [snip] Found it: http://d.puremagic.com/issues/show_bug.cgi?id=5605 Oo -- nice :) (That it should work, that is; not that it doesn't ;) -- Magnus Lie Hetland http://hetland.org

Re: Overriding in operator

2011-03-04 Thread Magnus Lie Hetland
solution, really. I just didn't know of it :) -- Magnus Lie Hetland http://hetland.org

Re: Overriding iteration

2011-03-04 Thread Magnus Lie Hetland
, too, iterators (i.e., ranges) and iterables (i.e., containers) are separate concepts. You can iterate over an iterable, and the loop then automatically extracts an iterator. As this is The Way to Go, it makes sense to me that it's automatic/implicit. -- Magnus Lie Hetland http://hetland.org

Two questions about %a

2011-03-02 Thread Magnus Lie Hetland
in functionality? Second question: Just to make sure, this *is* an exact representation of the underlying floating-point number? (I.e., if that'w what I'm after, using %a *is* the way to go?) -- Magnus Lie Hetland http://hetland.org

Re: @property ref foo() { ...} won't work...?

2011-03-02 Thread Magnus Lie Hetland
On 2011-03-01 13:20:18 +0100, Steven Schveighoffer said: On Tue, 01 Mar 2011 07:19:21 -0500, Lars T. Kyllingstad public@kyllingen.nospamnet wrote: On Tue, 01 Mar 2011 12:25:30 +0100, Magnus Lie Hetland wrote: 2. How can I make r.front = foo work, when I only have r.front(), returning a ref

Re: How do you test pre-/post-conditions and invariants?

2011-02-28 Thread Magnus Lie Hetland
On 2011-02-27 02:33:46 +0100, Jonathan M Davis said: [snip lots of useful stuff] Thanks for your patience, and more useful clarifications. I think I get it now (but I may very well be wrong ;) - M -- Magnus Lie Hetland http://hetland.org

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Magnus Lie Hetland
preconditions really simple. (And any utility functions I use in them can then get unit tests of their own instead ;) That's probably a good way to handle it . OK, good :) -- Magnus Lie Hetland http://hetland.org

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Magnus Lie Hetland
On 2011-02-26 13:15:58 +0100, Jonathan M Davis said: On Saturday 26 February 2011 03:24:15 Magnus Lie Hetland wrote: OK. I had the impression that using assert() in contracts was standard, also for API functions. I thought contracts fulfilled a similar sort of function to assert

Re: How do you test pre-/post-conditions and invariants?

2011-02-26 Thread Magnus Lie Hetland
. That sounds quite in line with programming by contract to me ... but then, again, I'm a reall n00b on the subject :) -- Magnus Lie Hetland http://hetland.org

Is std.cover deprecated or gone?

2011-02-26 Thread Magnus Lie Hetland
reports end up (unless I examine the path to the generated executable), so I thought I'd specify where I wanted them... -- Magnus Lie Hetland http://hetland.org

Re: Is std.cover deprecated or gone?

2011-02-26 Thread Magnus Lie Hetland
On 2011-02-26 16:30:10 +0100, Magnus Lie Hetland said: It's documented here... http://www.digitalmars.com/d/2.0/phobos/std_cover.html ... but I can't find it in the Phobos source. (Also, I can't import it -- which is perhaps the most pressing issue :) It's just that I'm using rdmd

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-25 Thread Magnus Lie Hetland
, Python Algorithms, last fall ;) /OT -- Magnus Lie Hetland http://hetland.org

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-25 Thread Magnus Lie Hetland
arguments I supplied when running the script. The fact that --shebang borks the whole execution seems like it must be a bug. As for the rest of the behavior, it seems pretty useful to me, but perhaps OS X-specific? (That would be odd, but who knows...) -- Magnus Lie Hetland http

How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
that they will, in fact, throw when you break them.) -- Magnus Lie Hetland http://hetland.org

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
foo() catch (AssertError) thrown++; ... assert(thrown == k); I guess I could wrap it up a bit, or something. -- Magnus Lie Hetland http://hetland.org

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-25 17:48:54 +0100, spir said: On 02/25/2011 04:30 PM, Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what assert() throws -- so what's

Re: How do you test pre-/post-conditions and invariants?

2011-02-25 Thread Magnus Lie Hetland
On 2011-02-25 20:04:10 +0100, Jonathan M Davis said: On Friday, February 25, 2011 07:30:50 Magnus Lie Hetland wrote: Or, more generally, how do you test asserts (which is what I'm using in my preconditions etc.)? As far as I can see, collectException() won't collect errors, which is what

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-21 Thread Magnus Lie Hetland
. I just realized I didn't give a direct answer to your question: I'd say that most minor releases of DMD are *not* backward-incompatible. Thanks for both the thorough and the more direct answer. Very helpful/useful :) -- Magnus Lie Hetland http://hetland.org

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-21 Thread Magnus Lie Hetland
On 2011-02-20 19:22:20 +0100, Magnus Lie Hetland said: On 2011-02-19 22:25:31 +0100, Nick Sabalausky said: [snip] Unfortunately, rdmd doesn't seem to have gotten much attention lately. I've had a few patches for it sitting in bugzilla for a number of months. (Not that I'm complaning, I

Re: rdmd problems (OS X Leopard, DMD 2.052)

2011-02-20 Thread Magnus Lie Hetland
updating for 2.052. Hm. Are most minor releases of DMD backward-incompatible? (Sort of a scary prospect to me, at least...) -- Magnus Lie Hetland http://hetland.org

rdmd problems (OS X Leopard, DMD 2.052)

2011-02-19 Thread Magnus Lie Hetland
submit an issue about this? [1] http://www.digitalmars.com/d/2.0/rdmd.html -- Magnus Lie Hetland http://hetland.org

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-01-31 19:46:53 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Hm. Using code quite similar to you, supplying a lambda in the second aliasing, I get this error: something.d(93): Error: template instance cannot use local '__dgliteral2(__T3)' as parameter

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 10:11:53 +0100, Magnus Lie Hetland said: On 2011-01-31 22:21:40 +0100, bearophile said: Magnus Lie Hetland: [snip] I'm accustomed to is the ability to assign to multiple variables, such as arg, val = minArg(...) (Yeah, I'm a Python guy... ;) I will eventually add

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 10:49:23 +0100, bearophile said: Magnus Lie Hetland: Saw your post on digitalmars.D now, about the currying of templates (i.e., the main topic here). I guess perhaps that was what you were talking about? Tuple unpacking syntax and template currying are two different things

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 10:12:44 +0100, Magnus Lie Hetland said: On 2011-01-31 19:46:53 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Hm. Using code quite similar to you, supplying a lambda in the second aliasing, I get this error: something.d(93): Error: template

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 16:00:16 +0100, Magnus Lie Hetland said: import std.functional, std.stdio; int f(int x) {return x;} void main() { alias unaryFun!(f(a)) g; writeln(g(3)); } Just to be clear -- I realize I could just have used unaryFun!f here (or just f, for that matter

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
On 2011-02-01 16:09:22 +0100, Simen kjaeraas said: Magnus Lie Hetland mag...@hetland.org wrote: Sort of related (though perhaps only remotely) is the following, which won't compile (Error: static assert Bad unary function: f(a) for type int): Not related. unaryFun and binaryFun are simply

Re: Partially instantiating templates?

2011-02-01 Thread Magnus Lie Hetland
using the string ;) But, yeah, I understand how it works. Thanks. But thanks for noting that, I've filed it as issue #5513. Good. -- Magnus Lie Hetland http://hetland.org

Partially instantiating templates?

2011-01-31 Thread Magnus Lie Hetland
... (Perhaps even existing functionality for minArg/maxArg -- although the general question still stands.) -- Magnus Lie Hetland http://hetland.org

Re: Partially instantiating templates?

2011-01-31 Thread Magnus Lie Hetland
to hear that too. The best way to solve a problem is often to rephrase it :) -- Magnus Lie Hetland http://hetland.org

Re: Partially instantiating templates?

2011-01-31 Thread Magnus Lie Hetland
;-) At the moment, I'm using a mixing to create the min and max templates (as rather large strings). Probably not ideal. Thanks! -- Magnus Lie Hetland http://hetland.org

Re: Partially instantiating templates?

2011-01-31 Thread Magnus Lie Hetland
... Using optArg!a, for example, works just fine -- but the whole point was to include some local state. Using local functions worked (I think...?) when I had a global template. It seems D's compile-time computation system is less straightforward than I thought :) -- Magnus Lie Hetland http