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
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
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
) 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
;-)
But no problem -- not many lines to add to my own code.
--
Magnus Lie Hetland
http://hetland.org
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
?-)
--
Magnus Lie Hetland
http://hetland.org
surprised me that there wasn't a standard way of writing
file-related unit tests :)
--
Magnus Lie Hetland
http://hetland.org
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
, rather than
file-like objects, i.e., those with the appropriate methods...)
--
Magnus Lie Hetland
http://hetland.org
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
behavior? Perhaps it's been left
out for a reason? (Sounds sort of likely ;-)
--
Magnus Lie Hetland
http://hetland.org
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
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
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
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
) {
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
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
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
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
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
...
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
. (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
the collector is a bit over-eager...?
--
Magnus Lie Hetland
http://hetland.org
, probably Lion-related, bugs in my test suite...)
--
Magnus Lie Hetland
http://hetland.org
forgetting, other than type-based switch statements?)
Thanks,
- M
--
Magnus Lie Hetland
http://hetland.org
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
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
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
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
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
,
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
question:
3. How do you (canonically) make a growable heap using Phobos?
--
Magnus Lie Hetland
http://hetland.org
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
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
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
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
it there already.)
--
Magnus Lie Hetland
http://hetland.org
inferencebug.foo(T) cannot deduce
template function from argument types !()(uint[],real function(uint x,
uint y))
--
Magnus Lie Hetland
http://hetland.org
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
with it: http://stackoverflow.com/questions/4219600/logical-const-in-d
Thanks for the insights + tip :)
--
Magnus Lie Hetland
http://hetland.org
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 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
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
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
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
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
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
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
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
, 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
. Also, there's no core.memory link in the sidebar...)
--
Magnus Lie Hetland
http://hetland.org
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
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
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
elsewhere in my code,
preventing the operator overloading to take force.
Suggestions/solutions?-)
--
Magnus Lie Hetland
http://hetland.org
foreach(e; foo[])? Is there no way
to get this functionality directly (i.e., for foreach(e; foo))?
--
Magnus Lie Hetland
http://hetland.org
reporting?
Anwyay: Thanks for the clarification :)
--
Magnus Lie Hetland
http://hetland.org
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
solution, really. I just didn't know of it :)
--
Magnus Lie Hetland
http://hetland.org
, 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
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
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
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
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
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
.
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
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
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
,
Python Algorithms, last fall ;)
/OT
--
Magnus Lie Hetland
http://hetland.org
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
that they will, in
fact, throw when you break them.)
--
Magnus Lie Hetland
http://hetland.org
foo() catch (AssertError) thrown++;
...
assert(thrown == k);
I guess I could wrap it up a bit, or something.
--
Magnus Lie Hetland
http://hetland.org
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
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
.
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
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
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
submit an issue about this?
[1] http://www.digitalmars.com/d/2.0/rdmd.html
--
Magnus Lie Hetland
http://hetland.org
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
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
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
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
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
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
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
...
(Perhaps even existing functionality for minArg/maxArg -- although the
general question still stands.)
--
Magnus Lie Hetland
http://hetland.org
to hear that too. The best way to solve a problem is often
to rephrase it :)
--
Magnus Lie Hetland
http://hetland.org
;-)
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
...
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
90 matches
Mail list logo