On Thursday, May 03, 2012 07:00:21 James Miller wrote:
> I'm doing C bindings and I have an opaque struct and an extern'd
> variable of the type of that struct. The problem is that dmd is
> complaining that the struct has no definition (which is true).
> Making it a pointer works (expected) but i c
I'm doing C bindings and I have an opaque struct and an extern'd
variable of the type of that struct. The problem is that dmd is
complaining that the struct has no definition (which is true).
Making it a pointer works (expected) but i can't do that because
the interface is expecting an full str
Andrej Mitrovic:
This writes "yes" so cast is a blunt tool that doesn't work in
this case. to!() doesn't work either (compile error, maybe I
should file this) .
Seems worth filing.
Anyone know of any other solutions?
Write your own function to perform the test, using a liner loop?
Bye,
import std.stdio;
enum Base
{
One,
Two,
Three,
Four
}
enum Subset : Base
{
Two = Base.Two,
Three = Base.Three
}
void main()
{
Base base = Base.Four;
if (cast(Subset)base)
{
writeln("yes");
}
}
This writes "yes" so cast is a blunt tool that doesn't
Joseph Rushton Wakeling:
Removing the ref ups the time as described before, but only
with GDC (DMD the runtime is the same). It's a real effect.
There is no implicit local copy for const. I have a suspicion
that you changed
two things and forgot about one of them when running your
tests.
On 5/3/12, Andrej Mitrovic wrote:
> import std.stdio;
>
> struct Foo
> {
>int[] hash;
> }
Sorry that should have been int[int] there.
On 5/2/12, Jonathan M Davis wrote:
> The way that AAs work in this regard is identical to how dynamic arrays
> work.
Yes but they're very different in other regards. For example, if you
add an element to one array it doesn't automatically add an element to
the other array:
int[] a = new int[
Other, shorter example:
[code]
import std.stdio, std.traits;
class A {
int val;
alias val this;
T opCast(T : Object)() {
writeln("FOO");
return to!(T)(this);
}
}
class B : A {
}
T to(T : Object, U : Obj
H. S. Teoh:
I was told that this was expected behaviour.
It's trash behavior, bug-prone and not intuitive. It has the
worst qualities of both a struct and a class :-)
Should the new AA implementation change this, so that it always
allocates an empty AA upon instantiation?
Sounds like a po
Jacob Carlborg:
Is there a general function for transforming a range back to
the original type? If not, would it be possible to create one?
The newly redesigned containers in Scala language are often able
to do this, but this has required the use of a very advanced
static type system, that is
On Wednesday, May 02, 2012 23:01:21 Jacob Carlborg wrote:
> Is there a general function for transforming a range back to the
> original type? If not, would it be possible to create one?
You mean that if you have something like
auto range = getRangeFromSomewhere();
auto newRange = find(filter!func
On Wednesday, May 02, 2012 13:32:04 H. S. Teoh wrote:
> On Wed, May 02, 2012 at 09:38:35PM +0200, Andrej Mitrovic wrote:
> [...]
>
> > So if the hash wasn't already initialized then the reference in the
> > Foo struct is a reference to null, and if you duplicate that reference
> > and add a key th
On 05/02/2012 05:01 PM, Jacob Carlborg wrote:
Is there a general function for transforming a range back to the
original type? If not, would it be possible to create one?
I believe std.array's array function does what you want.
-Matt
Is there a general function for transforming a range back to the
original type? If not, would it be possible to create one?
--
/Jacob Carlborg
Can anyone tell me, why the this code
[code]
module RefTest.Ref;
import std.stdio : writeln;
import std.conv : to, toImpl;
T const_cast(T : Object)(const T obj) {
return cast(T) obj;
}
struct Ref(T : Object) {
private:
T _obj;
public:
@disable
this();// { }
On Wed, May 02, 2012 at 09:38:35PM +0200, Andrej Mitrovic wrote:
[...]
> So if the hash wasn't already initialized then the reference in the
> Foo struct is a reference to null, and if you duplicate that reference
> and add a key the old reference still points to null.
>
> The only way to ensure a
On 30/04/12 16:03, Steven Schveighoffer wrote:
Try removing the ref and see if it goes back. That usage of ref should not
affect anything (if anything it should be slower, since it's an extra level of
indirection).
Removing the ref ups the time as described before, but only with GDC (DMD the
r
import std.stdio;
struct Foo
{
int[int] hash;
}
void main()
{
test1();
test2();
}
void test1()
{
Foo foo;
foo.hash[1] = 1;
auto hash2 = foo.hash;
hash2[2] = 2;
writeln(foo.hash); // [1:1, 2:2]
writeln(hash2); // [1:1, 2:2]
}
void test2()
{
Foo foo;
Just got the TDPL book and it's a great read! I learn best when
typing out the code myself, so I decided to make a single VisualD
project and put the different exercises in separate modules. I am
having problems with sort in std.algorithms - well, actually it
appears to be a closure problem whe
On 04/30/2012 11:03 PM, bearophile wrote:
Christian Köstlin:
reduce!((int a, int b){return a+b;})(iota(100))
reduce!("a+b")(iota(100))
Today the syntaxes I prefer are:
iota(100).reduce!q{a + b}()
iota(100).reduce!((a, b) => a + b)()
But hopefully in some we'll have an efficient sum() funct
Hi all,
Looking into the source (it uses DM's libc) did I get right that
std.stdio.File can't work with UTF16 names in Windows?
I've tried to find bug# but failed too. There is Issue#7648 "Can't open
file (Windows UTF8)" only but UTF8 is not native for
Windows filesystems anyway. Is there any
On 05/02/2012 01:46 AM, bearophile wrote:
This is the brief of some D code, it shows one consequence of the
excessive overloading of the D "static" keyword:
struct Foo {
bool solve() {
/*static*/ bool fill(int r, int c, Cell n) {
// ...
if (fill(r + i, c + j,
22 matches
Mail list logo