On Sunday, 6 September 2015 at 10:12:58 UTC, ParticlePeter wrote:
In the end all that I want is "just" to disable access to
array.length through vector and alias this array.
struct Vec(T, size_t n = 3)
{
T[n] data;
alias data this;
@disable @property size_t length() const;
}
void
ument list should be optional anyway.
It would be a compiler bug. As far as I know, accepter() and
accepter!()() has no difference in IFTI.
I filed the issue in bugzilla.
https://issues.dlang.org/show_bug.cgi?id=14174
Kenji Hara
he issue in bugzilla:
https://issues.dlang.org/show_bug.cgi?id=14083
And will open a new pull request to fix compiler.
Kenji Hara
AAs or can I preserve my
convenient foreach over the AAs in the `static this` to
automatically get the integer value to be stored?
Note that this does not segdefault on latest stable DMD 2.066.
It's a regression in git-head.
https://issues.dlang.org/show_bug.cgi?id=14038
Kenji Hara
block assignment as a construction for
the field Bar.foo.
Kenji Hara
ble(double a) { writeln(typeof(a).stringof);
return a; }
float foo_float (float a) { writeln(typeof(a).stringof);
return a; }
}
alias foo = foo_double;
alias foo = foo_float;
void main()
{
double d;
float f;
foo(d); // prints double
foo(f); // prints float
}
Kenji Hara
help!
I commented in github.
Kenji Hara
On Monday, 31 March 2014 at 11:51:50 UTC, Olav Lindekleiv wrote:
Here's the issue:
http://d.puremagic.com/issues/show_bug.cgi?id=12498
Fixed in git-head.
https://github.com/D-Programming-Language/dmd/commit/2c4d8ad711ccb7c94d349830523dd500580b0130
Kenji Hara
reported, someone will close it as a "duplicate"
-Steve
I filed it.
https://d.puremagic.com/issues/show_bug.cgi?id=12508
Kenji Hara
On Sunday, 9 March 2014 at 11:21:19 UTC, Jack Applegame wrote:
This fails to compile
http://dpaste.dzfl.pl/e9a90e808af4
It's a compiler bug.
https://d.puremagic.com/issues/show_bug.cgi?id=12334
https://github.com/D-Programming-Language/dmd/pull/3371
Kenji Hara
'm afraid that allowing foo([4, 5, 6]s) would easily cause
memory corruption. I don't want to hurt language future by the
trivial syntactic sugar.
Kenji Hara
plate code bloat.
void foo(T)(T arg) { ... }
foo("aaa"); // instantiate foo!(char[3])
foo(""); // instantiate foo!(char[4])
foo([1,2]);// instantiate foo!(int[2])
foo([1,2,3]); // instantiate foo!(int[3])
So their types were changed to dynamic array by default.
Kenji Hara
literal should
match _only_ dynamic array types, it would never work.
Because compiler will try to match array literal to static array
T[n]. The feature which I have described is working here.
Kenji Hara
#x27;; // character literal has char type by default
dchar d = 'A'; // but it may be implicitly typed as wchar/dchar
string str = "hello";
dstring dstr = "hello"; // string literal is implicitly typed as
dstring
int[] darr = [1,2,3];
int[3] darr = [1,2,3]; // implicitly typed as int[3]
So, an array literal [1,2,3] is implicitly convertible both to
int[] and int[3].
And, int[3] is more specialized than int[], so overload
resolution will choose the first 'bar'.
Kenji Hara
//num = n; // also NG, my_integer cannot *initialize* by
int value
num = my_interger(n); // OK
}
}
Kenji Hara
Linux with 64 bit, but it fails on Windows
7 32 bit.
Bug, feature or my fault?
Compiler bug.
https://d.puremagic.com/issues/show_bug.cgi?id=11662
Kenji Hara
n, so it has
more bugs.
Bye,
bearophile
It's a known front-end issue.
https://d.puremagic.com/issues/show_bug.cgi?id=11545
Kenji Hara
e a report is needed
thanks to everyone
I found two compiler issues:
https://d.puremagic.com/issues/show_bug.cgi?id=11627
https://d.puremagic.com/issues/show_bug.cgi?id=11629
Kenji Hara
akes by far the most sense IMHO to just finish implementing
it. But when that
happens is up to the compiler devs, and at this point, I'm a
library dev, not
a compiler dev.
- Jonathan M Davis
I opened a new pull request to fix the compiler issue.
https://github.com/D-Programming-Language/dmd/pull/2832
Kenji Hara
main() {
auto d = new D();
assert(d.foo() == 3);// calls D.foo
assert(d.B.foo() == 1); // calls B.foo
assert(d.C.foo() == 2); // calls C.foo
d.test();
}
=====
Kenji Hara
char('a');
auto x = char('à'); // compile-time error
Kenji Hara
// But the two concatenations didn't reallocate underlying
memory.
}
And I don't recommend to use std.exception.assumeUnique, because
it is just a cosmetic function to make ugly (but necessary for
some reason) array cast grep-able and human-readable.
Kenji Hara
closure variables + scoped destruction should
be rejected, but currently it isn't. It's a compiler bug.
http://d.puremagic.com/issues/show_bug.cgi?id=11382
Kenji Hara
initely a front-end bug. However I'm not sure the
current ABI definition issue (== #2) is a language spec bug or
not...
Kenji Hara
function" error.
I filed a bug report and posted possible compiler fix.
http://d.puremagic.com/issues/show_bug.cgi?id=11286
https://github.com/D-Programming-Language/dmd/pull/2677
Kenji Hara
c.com/issues/show_bug.cgi?id=11187
And, a week ago it is fixed. 2.064 beta1 contains the fix.
Kenji Hara
nding attributes of
the underlying type's methods.
std.typecons.Proxy is designed to work transparently for the
underlying method qualifiers. But I also agree that the
implementation is still insufficient.
Could you show us the "not working" case? It would be much help.
Kenji Hara
he module import boundary.
Therefore, the use of 'X' in main.d would prefere the `mixin
A!("a in main") X`.
On the other hand, when the name search, all mixed-in symbols are
treated as if they are just imported at the mixed-in scope.
Therefore, even from main.d, the two mixed-in functions 'a' have
same closeness, and the call is ambiguous because they have
exactly same signature.
Kenji Hara
value type, but the
behavior was not changed.
As far as I know, there was no discussion about that, but at
least it is not fundamentally wrong.
Kenji Hara
And what is your personal opinion?
I think an implicit cast between signed / unsigned would be
acceptable even with static arrays. It were
or was expected.
In D2, static array had changed to value type, but the behavior
was not changed.
As far as I know, there was no discussion about that, but at
least it is not fundamentally wrong.
Kenji Hara
t foo(); }
mixin template Foo()
{
override int foo() { return 1; }
}
class C1 : I {
mixin Foo!();
}
class C2 : I
{
int foo() { return 10; }
mixin Foo!();
// mixed-in foo is not stored in vtbl
}
void main()
{
assert(new C1().foo() == 1);
assert(new C2().foo() == 10);
}
e is suppressed for later UFCS symbol
search.
But UFCS cannot find module level function 's', then compiler
reports irrelevant error message "no property 's'"
Kenji Hara
opDispatch!("to") isn't
a template
}
Should the constraint on opDispatch allow the UFCS "to" call on
S?
That's a compiler bug.
http://d.puremagic.com/issues/show_bug.cgi?id=10526
Kenji Hara
02d", time.year,
time.month, time.day, time.hour, time.minute, time.second);
}
In this case, format std.string.format function should work under
the `safe annotation.
I recently worked to make it possible.
https://github.com/D-Programming-Language/phobos/pull/1337
Kenji Hara
, but unfortunately it
is not yet merged.
https://github.com/D-Programming-Language/dmd/pull/1660
Kenji Hara
pragma(msg, C.TypeID, ", ", BaseClassesTuple!C); // 3, (B, A,
Object)
pragma(msg, D.TypeID, ", ", BaseClassesTuple!D); // 4, (C, B, A,
Object)
Kenji Hara
// or
alias tp = TypeTuple!(__traits(getAttributes, mixin(`a.`
~ it)));
writeln(`passing: `, tp[0]);
bar!(tp[0])();
}
}
Kenji Hara
data) {
pragma(msg, "static, E = ", E, ", N = ", N);
}
void foo(E)(E[] data) {
pragma(msg, "dynamic, E = ", E);
}
void main() {
foo("test"); // static
auto s = "test";
foo(s); // dynamic
}
Kenji Hara
On Wednesday, 29 May 2013 at 14:50:36 UTC, bearophile wrote:
Dicebot:
I think this is a bug.
It will be fixed progressively in the next two or three DMD
versions.
Bye,
bearophile
Please file it in bugzilla.
Kenji Hara
ual!T == enum))
{
return cast(T)as!(OriginalType!T);
}
}
void main() {
S val = S(-20);
assert(val.as!int == -20);
assert(val.as!E == E.F); // val.as!E causes a compile time
error.
}
---
This is a compiler regression in 2.063 release.
http://d.puremagic.com/issues/show_bug.cgi?id
// prints a
enum E2 { a = 10, b = 20 }
writefln("%s", E2.a);// prints a
enum E3 : string { a = "aaa", b = "bbb" }
writefln("%s", Ee.a);// prints a
If you want to make a set of compile time values, you can write
as follows:
struct application // or class
{
enum name = "my-app",
revision = "1.0a";
}
Kenji Hara
is a true sub-typing. So sometimes tuples with
named fields are sub-types and in other situations they act in
a structural typing way. I think this mix of behaviours is a
little confusing.
Basically Tuple would follow structural typing. Even if it is
impossible, it would follow true subtyping right now. That's the
purpose of my change.
Kenji Hara
a subtype of the
other:
import std.typecons: Tuple;
void main() {
alias T1 = Tuple!(int, int);
alias T2 = Tuple!(int,"x", int,"y");
auto t1 = T1(10, 20);
auto t2 = T2(100, 200);
t1 = t2; // OK.
t2 = t1; // OK?
}
std.typecons.Tuple supports "structural assignment" before the
change.
The code also works with 2.062.
Kenji Hara
On Thursday, 9 May 2013 at 18:25:39 UTC, Mike Linford wrote:
On Thursday, 9 May 2013 at 09:52:12 UTC, Kenji Hara wrote:
On Thursday, 9 May 2013 at 05:01:15 UTC, Mike Linford wrote:
I'm not sure whether or not I've encountered a bug or whether
my understanding of scoped imports is j
language design.
Kenji Hara
12 I'm able to use the static assert but *not* the runtime
assert. Why cant the function Blah.blah() find the array
implementation of front?
This is a known UFCS name look-up issue.
In 2.063dev, the bug is fixed. Please wait the release.
Kenji Hara
};
return dg; // escape! (should be rejected statically)
}
If compiler does not reject escape...
void main()
{
const int[] a = [3, 4, 5];
auto dg = foo(a);
// typeof(dg) == inout(int[]) delegate(inout(int[]))
int[] b = dg([]);
assert(b.ptr == a.ptr); // type-system breaking!
}
Kenji Hara
the type.
So, `alias TX` will bind the template Tuple. There is no problem.
Kenji Hara
fic detail I should
not ever use?
It is implementation specific. You must not rely on that.
Kenji Hara
On Monday, 28 January 2013 at 03:16:24 UTC, cal wrote:
This fails:
void main() {
int z;
typeof((int a){return z;}) dg;
dg = (int a) {return z;};
}
Error: cannot implicitly convert expression (__lambda2) of type
int delegate(int a) nothrow @safe to int delegate(int a) pure
nothrow
x27; is directly replaced to 'const', and it is
treated as a part of parameter type.
'inout' is also treated as a type qualifier, and then is the same.
Kenji Hara
(is(typeof(mixin("A."~ident~".offsetof" {}
Kenji Hara
licit casting from Foo to
immutable(Foo),
// because compiler can guarantee the instance 'foo' doesn't
have
// mutable indirections to any global data so makeFoo is a
pure function.
}
void main()
{
immutable ifoo = makeFoo();
}
Kenji Hara
should
work anyway.
This looks like a bug in the compiler to me.
What do you guys think?
This issue looks like bug8093.
http://d.puremagic.com/issues/show_bug.cgi?id=8093
And the code works correctly in git head (dmd2.061alpha).
Therefore, I think that the bug is fixed very recently.
Kenji Hara
n numerous occasions, and
it's among
his top thousand wanted features. :p
I think this is a bug in IFTE.
Please file it into bugzilla.
Kenji Hara
Then you cannot get offsetof property from _t;
Regards.
Kenji Hara
On Wednesday, 8 August 2012 at 23:21:32 UTC, Ellery Newcomer
wrote:
say I have
template T(alias fn) {
}
class Foo {
int i();
void i(int);
}
alias T!(Foo.i) Biz;
Is there a way to get a handle to both of the overloads of
Foo.i inside T?
Actually, all I really need for that is to get 'Fo
On Tuesday, 7 August 2012 at 16:11:05 UTC, Andrej Mitrovic wrote:
On 8/7/12, "Øivind" wrote:
How can I call this function with an already-constructed tuple
but pass the pule as an expressiontuple?
auto v = tuple(1, 2, 3);
f(v);
Use the .expand property:
f(v.expand)
You can also use slice o
x27;s id but i can still
print the correct id.
Implicit Copy CTor? ;)
Array appending and struct postblit behavior is now broken.
I've suggested a pull request to fix these bugs.
https://github.com/D-Programming-Language/dmd/pull/1037
Bye.
Kenji Hara
ic.com/issues/show_bug.cgi?id=8252
Kenji Hara
seems to
have been fixed. Feel free to create a new ticket.
That's what I do now. Thanks a lot for your help.
Today I posted a pull to detect recursive alias this dependency.
https://github.com/D-Programming-Language/dmd/pull/1028
Bye.
Kenji Hara
http://d.puremagic.com/issues/show_bug.cgi?id=6336
I've already posted a pull request to fix the bug, but it has
been hold a while.
Kenji Hara
d in f() without
using templates as in g()?
The type of 'alias this' symbol works as like the super class of
user defined class.
Therefore, Ranged!(...) is always implicitly convertible to int
by 'alias _value this', and there is no way to disable such
conversion.
Kenji Hara
y, this is a dmd bug that yet not fixed.
http://d.puremagic.com/issues/show_bug.cgi?id=6036
As far as I know, there is no workaround...
Kenji Hara
haracters.
So empty string always throws exception.
Kenji Hara
ast(Rect!int) o);
write("template cast: ");
Rect!int ri = template_cast!(Rect!int)(o);
write("Result: ");
writeln(ri);
}
Rect!(float) rf = new Rect!(float)();
foo(rf);
[/code]
Seems to me that you achieved the your first purpose. Do you need
more help?
Kenji Hara
On Thursday, 21 June 2012 at 10:33:41 UTC, Namespace wrote:
To solve the problem of converting a Object to a specific
template class i wrote this little function.
But the mixin disturbs me. How i can get the type (in this
example Vector2D) without to mix a mixin and T.stringof?
[code]
T object
t-wise array conversion'.
As a result, string[] to Wrap[] will be converted.
...but, this does not work in 2.060head, it is a bug.
Kenji Hara
On Wednesday, 6 June 2012 at 18:12:39 UTC, Namespace wrote:
If i have this code:
class Bar {
public:
Foo GetFoo() {
return this._foo;
}
alias GetFoo this;
}
to allow access to Foo methods from Bar i get the error, that
"GetFoo" isn't a property if i use -property.
Why?
The solution
On Sunday, 20 May 2012 at 06:57:20 UTC, Kenji Hara wrote:
On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote:
On 2012-05-19 15:28, Philippe Sigaud wrote:
On Sat, May 19, 2012 at 12:23 PM, Matthias Walter
wrote:
I would open a bug report with the following code which is a
bit
On Sunday, 20 May 2012 at 06:57:20 UTC, Kenji Hara wrote:
On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote:
Using the current git version of dmd I realized that C works!
Hence, as
a workaround it can be used by creating a local alias A and
subsequently
using A.Alias in the is
On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote:
On 2012-05-19 15:28, Philippe Sigaud wrote:
On Sat, May 19, 2012 at 12:23 PM, Matthias Walter
wrote:
I would open a bug report with the following code which is a
bit smaller
than my first wrong version:
=
On Thursday, 10 May 2012 at 07:32:42 UTC, Namespace wrote:
Can you explain me how TemplateThisParameter works? I read in
the
manual but a more detail explanation would help me a lot.
Hmm, I have thought following code should work about foo, but
doesn't.
import std.stdio;
struct Proxy
{
On Wednesday, 9 May 2012 at 06:42:09 UTC, Namespace wrote:
On Wednesday, 9 May 2012 at 04:49:39 UTC, Kenji Hara wrote:
On Tuesday, 8 May 2012 at 22:58:07 UTC, Namespace wrote:
In my development of the Ref / NotNull structure, I came
across a
problem: All the methods of "Proxy" are
in()
{
Proxy!S p;
//p.f(); // inside Proxy.f, typeof(o) == inout
p.g();
}
'Proxy' object should forward its 'this' type to original object.
For the purpose, TemplateThisParameter ('this T') works as
expected.
Kenji Hara
ere is not yet general way.
The definition of unformatValue for user-defined type in
different module isn't considered by std.format module. D's
module system is closed in basic.
Kenji Hara
)); // <-- success
}
Is that a bug or a feature? I might have opened it but I don't
remember now. :)
Ali
Bye.
Kenji Hara
StructLiteral:
http://dlang.org/struct.html#StructLiteral
and it is an expression.
Bye.
Kenji Hara
; <--- Fail !
-
'alias A' is TemplateAliasParameter, and it matches both symbols
and values.
Then A matches with the value "Hello", but doesn't with the type
string.
(string is an aliased name of immutable(char)[], and it is
built-in array type.)
http://dlang.org/template.html#TemplateAliasParameter
Kenji Hara
template generate( T... )
{
static assert(T.length%2==0 && is(typeof(T[1]) :
string)); // check
enum string value = "if( cmd == \"" ~ T[1] ~ "\")"
~ "return Command." ~ T[0] ~ ";"
~ "else "
~ generate!(T[2..$]).value;
}
//[snip]
}
Bye.
Kenji Hara
command line wrapper
gdmd), function literal always deduced as 'delegate'. So this
expression raises an error about type mismatching Lhs of 'int
function(int)' and Rhs of 'int delegate(int) pure nothrow'.
Then, specifying explicit 'function' will resolve issue:
alg.funcio = function(int a) { return 2 * a; };
Bye.
Kenji Hara
t the code above accept the const(int []) ?
Should do. It is a compiler bug.
I've filed this issue in bugzilla:
http://d.puremagic.com/issues/show_bug.cgi?id=7929
And posted a pull request to fix compiler code:
https://github.com/D-Programming-Language/dmd/pull/884
Thanks.
Kenji Hara
2:
[snip]
Current std.format doesn't support const class formatting with
upcasting to mutable Object and using mutable toString().
Is this good/expected?
It is a gap between language const system and object.Object class
interface.
I think Phobos should not break const system in basic.
Kenji Hara
On Tuesday, 27 March 2012 at 13:42:30 UTC, Tongzhou Li wrote:
Hello again! I'm learning D, and I encountered a problem.
I tried this code:
http://ideone.com/hkpT6
It works well. (Have no idea why codepad.org failed to compile
it)
I tried to write a lambda instead of function f, but I got
nothin
On Friday, 23 March 2012 at 23:01:43 UTC, Timon Gehr wrote:
On 03/23/2012 11:58 PM, David wrote:
Am 23.03.2012 23:52, schrieb H. S. Teoh:
Code:
struct S {
int f(K)(K x) {
return 1;
}
void func(K)(inout(K) x) {
auto h = f(x);
}
}
void main() {
S s;
s.func("abc"); // This is line 44
}
This refus
On Wednesday, 21 March 2012 at 01:26:23 UTC, bearophile wrote:
import std.stdio;
void main() {
auto mat = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]];
writefln("%(%(%d %)\n%)", mat);
writeln();
writefln("[%(%(%d %)\n%)]", mat);
writeln();
w
On Monday, 5 March 2012 at 22:31:58 UTC, H. S. Teoh wrote:
OK, it's a bit ugly I supopse, but I can live with that.
Is there a way to tell whether or not a given class is a
derived class
or not? I'm using the Serializable template to insert
serialize() into
the class, and for derived classes
87 matches
Mail list logo