Why TypeTuple can be assigned to a variable

2013-06-12 Thread Zhenya
Hi! I was just surprised when realized, that this code compiles and runs: import std.typetuple; import std.stdio; void main() { auto foo = TypeTuple!(foo,bar); writeln(typeid(typeof(foo))); writeln(foo); } If I were compiler expert,I'd say that it's a bug.But I am not) So, can anybody

Re: Why TypeTuple can be assigned to a variable

2013-06-12 Thread Zhenya
On Wednesday, 12 June 2013 at 08:14:06 UTC, Simen Kjaeraas wrote: On Wed, 12 Jun 2013 10:01:59 +0200, Zhenya zh...@list.ru wrote: Hi! I was just surprised when realized, that this code compiles and runs: import std.typetuple; import std.stdio; void main() { auto foo = TypeTuple!(foo,bar

Re: Why TypeTuple can be assigned to a variable

2013-06-12 Thread Zhenya
On Wednesday, 12 June 2013 at 10:09:07 UTC, Simen Kjaeraas wrote: On Wed, 12 Jun 2013 11:44:19 +0200, Zhenya zh...@list.ru wrote: OK,you say that TypeTuple!(foo,bar) is a cool value of type TypeTuple!(string,string),right? Well, yes and no, not really. It's a bit magical. In your case, it's

Re: question with compile-time reflection

2013-03-10 Thread Zhenya
And since alias can represent any symbol,i think that it's correct usage.

Re: question with compile-time reflection

2013-03-10 Thread Zhenya
On Monday, 11 March 2013 at 00:10:46 UTC, Rob T wrote: template NDimensionalArrayType(T,alias size) I'm wondering what alias size does? I can't find that form documented anywhere, but it seems to be valid. Thanks. --rt It's just a little hack for known bug - only string and integer value

question with compile-time reflection

2013-03-09 Thread Zhenya
Hi! this code fails with message:NDimensionalArray.doIndex(Array) if (is(Array _ : NDimensionalArrayType!(T,s),const(int[]) s)) cannot deduce template function from argument types !()(int[2u][2u],const(int[])) Tell me please,am I wrong? And if yes,what should I change to make it work?

Re: question with compile-time reflection

2013-03-09 Thread Zhenya
On Saturday, 9 March 2013 at 23:05:56 UTC, Ivan Kazmenko wrote: this code fails with message:NDimensionalArray.doIndex(Array) if (is(Array _ : NDimensionalArrayType!(T,s),const(int[]) s)) cannot deduce template function from argument types !()(int[2u][2u],const(int[])) Tell me please,am I

Re: question with compile-time reflection

2013-03-09 Thread Zhenya
Although of course I would want to know what's wrong with constrait,because it protect doArray against incorrect using. I don't worry about effiency very much,I just wanted to right n-dimensional tree of intervals.And for doing it I needed n-dimensional array with opIndex like it.

Re: question with compile-time reflection

2013-03-09 Thread Zhenya
On Saturday, 9 March 2013 at 23:40:25 UTC, Zhenya wrote: Although of course I would want to know what's wrong with constrait,because it protect doArray against incorrect using. I don't worry about effiency very much,I just wanted to right n-dimensional tree of intervals.And for doing it I

typeof([2,2]) !=? int[2]

2013-03-08 Thread Zhenya
Hi! Explain me please,what's wrong with this code: struct NDimensionalArray(T,alias size) if(is(typeof(size) _ == int[n],int n) n 0) { static if(n 1) NDimensionalArray!(T,n - 1,size[1..$]) m_array[size[0]]; else T

Re: typeof([2,2]) !=? int[2]

2013-03-08 Thread Zhenya
On Friday, 8 March 2013 at 22:59:40 UTC, bearophile wrote: This is an answer to just your title question. A lot of time ago typeof([2,2]) was int[2]. This was efficient, but in most cases this was a source of troubles and bugs. So now a [2,2] is a heap-allocated dynamic array of type int[].

Re: typeof([2,2]) !=? int[2]

2013-03-08 Thread Zhenya
On Friday, 8 March 2013 at 23:03:47 UTC, Zhenya wrote: On Friday, 8 March 2013 at 22:59:40 UTC, bearophile wrote: This is an answer to just your title question. A lot of time ago typeof([2,2]) was int[2]. This was efficient, but in most cases this was a source of troubles and bugs. So now

Re: typeof([2,2]) !=? int[2]

2013-03-08 Thread Zhenya
On Friday, 8 March 2013 at 23:09:07 UTC, cal wrote: On Friday, 8 March 2013 at 23:03:47 UTC, Zhenya wrote: Your constraint could be: if(is(typeof(size) _ == int[]) size.length 0) Also it looks like you are passing 1 too many template args? static if(n 1) NDimensionalArray!(T,n - 1,size

Re: typeof([2,2]) !=? int[2]

2013-03-08 Thread Zhenya
On Friday, 8 March 2013 at 23:18:52 UTC, cal wrote: On Friday, 8 March 2013 at 23:15:30 UTC, Zhenya wrote: Yes,it's a typo.But it seems to be ugly pass dynamically allocated array through a template parameter,because it's size should be compile-time constant. Its size is a compile-time

enum function can't be passed into template?

2013-01-20 Thread Zhenya
Hi! Am I doing something wrong? import std.stdio; template gun(alias f) { void gun() { f(); } } void main() { auto str = hello; enum fun = (){writeln(str);};//replace enum - auto to compile gun!fun(); } Error:delegate

Re: enum function can't be passed into template?

2013-01-20 Thread Zhenya
On Sunday, 20 January 2013 at 14:51:51 UTC, Philippe Sigaud wrote: On Sun, Jan 20, 2013 at 3:21 PM, Zhenya zh...@list.ru wrote: Hi! Am I doing something wrong? import std.stdio; template gun(alias f) { void gun() { f(); } } void main() { auto

Re: does alias this work correctly?

2013-01-14 Thread Zhenya
On Sunday, 13 January 2013 at 22:36:03 UTC, Jonathan M Davis wrote: On Sunday, January 13, 2013 20:41:48 Zhenya wrote: On Sunday, 13 January 2013 at 19:35:08 UTC, Maxim Fomin wrote: According to spec http://dlang.org/class.html#AliasThis undefined lookups are forwarded to AliasThis member

Re: does alias this work correctly?

2013-01-14 Thread Zhenya
On Sunday, 13 January 2013 at 23:21:20 UTC, Andrey wrote: I just want very much avoid renaming function,it's principle for me. So I would like to know is my sample right or no. I think that the main overall principle here is that is it impossible to have two functions which differ only by

Re: does alias this work correctly?

2013-01-14 Thread Zhenya
On Sunday, 13 January 2013 at 22:36:03 UTC, Jonathan M Davis wrote: On Sunday, January 13, 2013 20:41:48 Zhenya wrote: On Sunday, 13 January 2013 at 19:35:08 UTC, Maxim Fomin wrote: According to spec http://dlang.org/class.html#AliasThis undefined lookups are forwarded to AliasThis member

Re: does alias this work correctly?

2013-01-14 Thread Zhenya
On Tuesday, 15 January 2013 at 00:04:15 UTC, Jonathan M Davis wrote: On Monday, January 14, 2013 17:57:03 Zhenya wrote: import std.stdio; struct Bar { void opDispatch(string op)() if(op == bar) { if(this !is m_init

static vs non-static

2013-01-13 Thread Zhenya
Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln(static); } void bar() { writeln(non-static); } } int main() { Foo gun; gun.bar();//fails here } Is it

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. Bye, bearophile Maybe you could suggest

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:17:54 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 16:23:27 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 16:18:36 UTC, Maxim Fomin wrote: Yes, it is a problem - dmd allows to call static functions on instance. When both match, it issues ambiguity

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote: Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() { writeln(static myfun); } }

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 18:16:40 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote: Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun

does alias this work correctly?

2013-01-13 Thread Zhenya
Hi! Is it all right with it: struct Foo { struct Bar { void opCall() { writeln(non-static); } } Bar bar; static struct Anotherbar { static void bar()

Re: does alias this work correctly?

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 19:35:08 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 19:16:36 UTC, Zhenya wrote: Hi! Is it all right with it: struct Foo { struct Bar { void opCall() { writeln(non-static

Passing member-function to template

2013-01-12 Thread Zhenya
Hi! Tell me please,is there any way to pass member-function to template? I need something like that: template execute(alias obj,alias mfun) { void execute() { obj.mfun(); } } struct Foo { void nothing() { } } void main() { Foo f;

Re: Passing member-function to template

2013-01-12 Thread Zhenya
On Saturday, 12 January 2013 at 19:06:27 UTC, Maxim Fomin wrote: On Saturday, 12 January 2013 at 18:17:47 UTC, Zhenya wrote: Hi! Tell me please,is there any way to pass member-function to template? Probably this can help: (you can manually construct a delegate combining function and context

Re: Passing member-function to template

2013-01-12 Thread Zhenya
On Saturday, 12 January 2013 at 19:24:04 UTC, Maxim Fomin wrote: On Saturday, 12 January 2013 at 19:16:02 UTC, Zhenya wrote: But I would like to handle not only member-function,but global function too(by UFCS) if it's possible. Global functions rewritten as UFCS functions are not delegates

Re: is(...) with alias this

2013-01-06 Thread Zhenya
On Saturday, 5 January 2013 at 22:17:08 UTC, monarch_dodra wrote: On Saturday, 5 January 2013 at 22:09:45 UTC, Philippe Sigaud wrote: I think the alias this transformation is done 'before' any usual conversion. I guess it's a real replacement inside the code (I'm not sure how to explain my

is(...) with alias this

2013-01-05 Thread Zhenya
Hi! I just read the David's post http://forum.dlang.org/thread/kc9e74$bg7$1...@digitalmars.com This code worked with dmd 2.060: import std.stdio; import std.traits; struct OhWhy(S) { S[] arr; alias arr this; } void main() { static assert(isArray!(OhWhy!(float))); }

Re: typeid + toString = runtime error

2012-12-30 Thread Zhenya
On Sunday, 30 December 2012 at 16:04:48 UTC, Ali Çehreli wrote: On 12/30/2012 07:32 AM, Zhenya wrote: Hi! Explain me please why this code fails in runtime: import std.stdio; class Foo { ~this() {writeln(typeid(this).toString ~ is dead);} } void main() { new Foo; } Application error

DList!(Tuple!(TypeInfo_Class)) causes compilation error

2012-12-30 Thread Zhenya
Hi! I just need DList!(Tuple!(TypeInfo_Class)) for my n-dimensional dispatcher, but compiler says: Error: function std.typecons.Tuple!(TypeInfo_Class).Tuple.opEquals!(const(Tuple!(TypeInfo_Class))).opEquals (const(Tuple!(TypeInfo_Class)) rhs) is not callable using argument types

Re: DList!(Tuple!(TypeInfo_Class)) causes compilation error

2012-12-30 Thread Zhenya
On Sunday, 30 December 2012 at 20:09:57 UTC, Zhenya wrote: Hi! I just need DList!(Tuple!(TypeInfo_Class)) for my n-dimensional dispatcher, but compiler says: Error: function std.typecons.Tuple!(TypeInfo_Class).Tuple.opEquals!(const(Tuple!(TypeInfo_Class))).opEquals (const(Tuple

Re: DList!(Tuple!(TypeInfo_Class)) causes compilation error

2012-12-30 Thread Zhenya
On Sunday, 30 December 2012 at 21:30:04 UTC, monarch_dodra wrote: On Sunday, 30 December 2012 at 20:09:57 UTC, Zhenya wrote: Hi! I just need DList!(Tuple!(TypeInfo_Class)) for my n-dimensional dispatcher, but compiler says: Error: function std.typecons.Tuple!(TypeInfo_Class).Tuple.opEquals

checking whether the number is NaN

2012-12-28 Thread Zhenya
Hi! Tell me please,are there any way to check whether number is NaN?

Re: checking whether the number is NaN

2012-12-28 Thread Zhenya
On Friday, 28 December 2012 at 15:59:35 UTC, bearophile wrote: Zhenya: Tell me please,are there any way to check whether number is NaN? http://dlang.org/phobos/std_math.html#isNaN Bye, bearophile Thank you!

Re: private with alias this

2012-12-25 Thread Zhenya
On Tuesday, 25 December 2012 at 07:21:12 UTC, evilrat wrote: On Tuesday, 25 December 2012 at 05:28:54 UTC, Zhenya wrote: On Tuesday, 25 December 2012 at 02:43:52 UTC, r_m_r wrote: On 12/25/2012 07:42 AM, r_m_r wrote: assert(!__traits(compiles, b._bar)); sorry, i made a typo: it should

Re: private with alias this

2012-12-24 Thread Zhenya
On Tuesday, 25 December 2012 at 02:43:52 UTC, r_m_r wrote: On 12/25/2012 07:42 AM, r_m_r wrote: assert(!__traits(compiles, b._bar)); sorry, i made a typo: it should be bar_ instead of _bar. Interestingly, the below assertion fails at run time: assert(!__traits(compiles, b.bar_)); but this

const property don't wont return const reference to value

2012-12-23 Thread Zhenya
Hi! Explain me please what's wrong with this code: module main; struct foo { int m_bar; @property const ref int bar() const { return m_bar; } } void main() { } Error: cast(int)this.m_bar is not an lvalue

Re: const property don't wont return const reference to value

2012-12-23 Thread Zhenya
On Sunday, 23 December 2012 at 13:37:33 UTC, Rainer Schuetze wrote: On 23.12.2012 14:20, Zhenya wrote: @property const ref int bar() const The first const does not bind to the return type, but to the whole declaration, so it does the same as the const at the end. You should use

opDispatch bug?

2012-12-15 Thread Zhenya
Hi! Is it a bug? class Foo { int m_bar; char m_gun; @property auto ref opDispatch(string s)() { return mixin(m_~s); } this(int i,char c) { bar = i;//Error: undefined identifier bar, did you mean variable m_bar?

Re: opDispatch bug?

2012-12-15 Thread Zhenya
On Saturday, 15 December 2012 at 18:09:00 UTC, Ali Çehreli wrote: On 12/15/2012 10:07 AM, Ali Çehreli wrote: Otherwise any type would go to opDispatch. Wow. I made a typo in typo. :) That should be: Otherwise any _typo_ would go to opDispatch. Ali It's pretty reasonable,thank you.

Re: Type value

2012-12-11 Thread Zhenya
On Tuesday, 11 December 2012 at 07:50:10 UTC, js.mdnq wrote: On Tuesday, 11 December 2012 at 07:15:38 UTC, Zhenya wrote: I'm sorry for my english. I know that D != Python and my example don't need any RTTI. D has alias this feature.My example shows that we can use alias this with types

Re: Type value

2012-12-11 Thread Zhenya
On Tuesday, 11 December 2012 at 09:40:08 UTC, Ali Çehreli wrote: On 12/11/2012 01:05 AM, Ali Çehreli wrote: /* Fundamental types must be made differently; probably due to syntax * issues. I would have expected for the following to work: * * return Type!index(args); // -- compilation error

Type value

2012-12-10 Thread Zhenya
Hi! In some previous post I asked about possibility of declar opIndex,that return type. I thoght about it,and I understood that code like this is legal: struct Type(T) { alias T m_type; alias m_type this; } void main() { Type!int Int; // Int a; } Is it hard to

Re: Type value

2012-12-10 Thread Zhenya
I'm sorry for my english. I know that D != Python and my example don't need any RTTI. D has alias this feature.My example shows that we can use alias this with types. And I just want use this: struct Type(T) { alias T m_type; alias m_type this; } int main() { Type!int Int; Int

VisualD solution configuration

2012-12-02 Thread Zhenya
Hi! I'm sorry,maybe it is a little bit stupid question,but how to configure VisualD project to get it compile not only main.d but all files in project?

Re: VisualD solution configuration

2012-12-02 Thread Zhenya
On Sunday, 2 December 2012 at 14:52:24 UTC, Lubos Pintes wrote: Not sure if I understand what you ask here, but you probably need to add all files you want to compile to the project. Thus not only the main.d, but all modules. Dňa 2. 12. 2012 11:56 Zhenya wrote / napísal(a): Hi! I'm sorry

Re: VisualD solution configuration

2012-12-02 Thread Zhenya
On Sunday, 2 December 2012 at 14:58:24 UTC, Zhenya wrote: On Sunday, 2 December 2012 at 14:52:24 UTC, Lubos Pintes wrote: Not sure if I understand what you ask here, but you probably need to add all files you want to compile to the project. Thus not only the main.d, but all modules. Dňa 2. 12

Re: VisualD solution configuration

2012-12-02 Thread Zhenya
On Sunday, 2 December 2012 at 15:03:26 UTC, Zhenya wrote: On Sunday, 2 December 2012 at 14:58:24 UTC, Zhenya wrote: On Sunday, 2 December 2012 at 14:52:24 UTC, Lubos Pintes wrote: Not sure if I understand what you ask here, but you probably need to add all files you want to compile

Re: VisualD solution configuration

2012-12-02 Thread Zhenya
On Sunday, 2 December 2012 at 20:12:08 UTC, Regan Heath wrote: On Sun, 02 Dec 2012 15:08:51 -, Zhenya zh...@list.ru wrote: On Sunday, 2 December 2012 at 15:03:26 UTC, Zhenya wrote: On Sunday, 2 December 2012 at 14:58:24 UTC, Zhenya wrote: On Sunday, 2 December 2012 at 14:52:24 UTC, Lubos

Can operators return type?

2012-11-29 Thread Zhenya
Hi! It would useful for some my project,if operators could be a template,that return type.Something like alias TypeTuple!(int,char) types; static assert(types[1] == char) //opIndex So can I define something like that?

Re: Can operators return type?

2012-11-29 Thread Zhenya
On Thursday, 29 November 2012 at 16:55:01 UTC, bearophile wrote: Zhenya: It would useful for some my project,if operators could be a template,that return type. D operators are functions, and D functions return values. And in D types are not values (unlike Python and several other

Re: Can operators return type?

2012-11-29 Thread Zhenya
On Thursday, 29 November 2012 at 21:53:20 UTC, bearophile wrote: Zhenya: For example: struct MyIntType { alias int type; template opSlice() { alias type opSlice; } As you guess, this is not supported in D. Bye, bearophile Thank you,understood(

Re: SList/DList ranges

2012-11-27 Thread Zhenya
On Tuesday, 27 November 2012 at 07:51:16 UTC, Jonathan M Davis wrote: On Monday, November 26, 2012 19:49:51 Zhenya wrote: Hi! I read the spec,but I didn't find any function,that removes concrete element from list.I am not familiar with D's ranges,so could you help me please? What do you mean

SList/DList ranges

2012-11-26 Thread Zhenya
Hi! I read the spec,but I didn't find any function,that removes concrete element from list.I am not familiar with D's ranges,so could you help me please?

DFL Button.backColor

2012-10-30 Thread Zhenya
Hi! Explain me please,why this code doesn't work import dfl.all; void main() { auto form = new Form; auto button = new Button; button.backColor = Color(0,0,0); button.foreColor = Color(0,0,0); form.controls.add(button); Application.run(form); }

Re: DFL Button.backColor

2012-10-30 Thread Zhenya
On Tuesday, 30 October 2012 at 13:34:21 UTC, Zhenya wrote: Hi! Explain me please,why this code doesn't work import dfl.all; void main() { auto form = new Form; auto button = new Button; button.backColor = Color(0,0,0); button.foreColor = Color(0,0,0

__traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Zhenya
Hi! Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) = true, is(typeof(check(arg))) = false. template ArgType(alias arg) { void check(T)(ref T t) {}; // static if(__traits(compiles,check(arg);))

Re: __traits(compiles,...) = ? is(typeof(...))

2012-10-29 Thread Zhenya
On Monday, 29 October 2012 at 10:58:51 UTC, Philippe Sigaud wrote: Tell me please,in this code first and second static if,are these equivalent? with arg = 1, __traits(compiles,check(arg);) = true, is(typeof(check(arg))) = false. __traits(compiles, ...) takes an expression, not a string. From

Re: TypeInfo manipulation

2012-10-27 Thread Zhenya
On Friday, 26 October 2012 at 19:57:14 UTC, Zhenya wrote: On Thursday, 25 October 2012 at 15:05:05 UTC, Zhenya wrote: Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried

Re: TypeInfo manipulation

2012-10-27 Thread Zhenya
What do you mean: to parametrize class by Typeinfo? class A { } A!TypeInfo var; If you mean this, than how it can help? It would be well if I could create object that inherits class with this typeinfo.

Re: TypeInfo manipulation

2012-10-27 Thread Zhenya
I have double dispatcher: template Dispatcher(R) { R execute(Left,Right)(R delegate(Left,Right) f,Object left,Object right) { return f(cast(Left)left,cast(Right)right); } struct Dispatcher { private R

Re: TypeInfo manipulation

2012-10-26 Thread Zhenya
On Thursday, 25 October 2012 at 15:05:05 UTC, Zhenya wrote: Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried to write some smart pointer that overlad classinfo

TypeInfo manipulation

2012-10-25 Thread Zhenya
Hi! Tell me please,are any TypeInfo/typeid/classinfo manipulations possible? For example I need a struct that overload typeid, or something like that? Some time ago I tried to write some smart pointer that overlad classinfo property in accordance with the real type of hold object,but I

Re: SFML-D working example

2012-10-21 Thread Zhenya
On Sunday, 21 October 2012 at 03:37:20 UTC, Ellery Newcomer wrote: On Saturday, 20 October 2012 at 20:25:09 UTC, Zhenya wrote: Hi!I have a little problem with building example.I downloaded SFML-D working example at this adress https://github.com/krzat/SFML-D/downloads.But then I tried

Re: SFML-D working example

2012-10-21 Thread Zhenya
On Sunday, 21 October 2012 at 07:34:29 UTC, Zhenya wrote: On Sunday, 21 October 2012 at 03:37:20 UTC, Ellery Newcomer wrote: On Saturday, 20 October 2012 at 20:25:09 UTC, Zhenya wrote: Hi!I have a little problem with building example.I downloaded SFML-D working example at this adress https

SFML-D working example

2012-10-20 Thread Zhenya
Hi!I have a little problem with building example.I downloaded SFML-D working example at this adress https://github.com/krzat/SFML-D/downloads.But then I tried to build it myself,I received many errors like that: Symbol Undefined

non-const reference to const instance of class

2012-10-10 Thread Zhenya
Hi! I thought that this should compile: class Foo{} const(Foo) foo = new Foo;// the same that const Foo foo? foo = new Foo; but compiler say that foo is const reference and it can't modify it. It is normally?If yes,how can I declare non-const reference to const instance of class?

Re: non-const reference to const instance of class

2012-10-10 Thread Zhenya
On Wednesday, 10 October 2012 at 17:35:48 UTC, Jonathan M Davis wrote: On Wednesday, October 10, 2012 19:02:31 Zhenya wrote: Hi! I thought that this should compile: class Foo{} const(Foo) foo = new Foo;// the same that const Foo foo? foo = new Foo; but compiler say that foo is const

this() in struct

2012-10-09 Thread Zhenya
Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor was disallowed in structs?

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor was disallowed in structs? And if I have to do some initialization of data members,what is the way to do it?

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 18:29:18 UTC, Jonathan M Davis wrote: On Tuesday, October 09, 2012 19:08:35 Zhenya wrote: On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 18:29:18 UTC, Jonathan M Davis wrote: On Tuesday, October 09, 2012 19:08:35 Zhenya wrote: On Tuesday, 9 October 2012 at 17:21:47 UTC, Zhenya wrote: Hi! I'm sorry,maybe this topic already was discussed,but could anybody explain me why default constructor

Re: this() in struct

2012-10-09 Thread Zhenya
On Tuesday, 9 October 2012 at 19:04:40 UTC, Jonathan M Davis wrote: On Tuesday, October 09, 2012 20:09:56 Zhenya wrote: Ok.Then can I do my own .init property that can be executed in compile-time? No. You directly initialize the member variables to what you want them to be, and that's

CFTE+DevIL=?

2012-10-08 Thread Zhenya
Hi! I need to load some textures for my game,but I woud like to do it in compile time. I know that CTFE imposes restrictions on functions.So can I execute some DevIL(Derelict3) functions?

Re: compiler assertion

2012-09-29 Thread Zhenya
On Saturday, 29 September 2012 at 13:03:31 UTC, Philippe Sigaud wrote: On Fri, Sep 28, 2012 at 10:32 PM, Zhenya zh...@list.ru wrote: Thank you,understood. This should work, hopefully: import std.stdio; import std.typetuple; template sum(U...) { static if(U.length == 0

compiler assertion

2012-09-28 Thread Zhenya
Hi! Is it normally,that this simple code does'nt compile with this assertion: dmd: template.c:5542: Identifier* TemplateInstance::genIdent(Objects*): Assertion `global.errors' failed. import std.stdio; import std.typetuple; template sum(T:TypeTuple!U,U...) { static if(U.length == 0)

Re: compiler assertion

2012-09-28 Thread Zhenya
On Friday, 28 September 2012 at 20:27:07 UTC, Jonathan M Davis wrote: On Friday, September 28, 2012 22:19:56 Zhenya wrote: Hi! Is it normally,that this simple code does'nt compile with this assertion: dmd: template.c:5542: Identifier* TemplateInstance::genIdent(Objects*): Assertion

Re: DerelictGL program draw nothing

2012-09-04 Thread Zhenya
But why it doesn't convert uint to int correctly?

Re: DerelictGL program draw nothing

2012-09-04 Thread Zhenya
On Tuesday, 4 September 2012 at 16:17:30 UTC, Ivan Agafonov wrote: On Tuesday, 4 September 2012 at 07:32:47 UTC, Zhenya wrote: But why it doesn't convert uint to int correctly? I dont know, small positive uint and int must have the same binary representation, and no need to conversion

import doesn't import jpg

2012-09-04 Thread Zhenya
immutable char[] texture = import(Chrysanthemum.jpg); fails with message: unrecognized type jpg but why?

Re: import doesn't import jpg

2012-09-04 Thread Zhenya
On Tuesday, 4 September 2012 at 19:04:33 UTC, Zhenya wrote: On Tuesday, 4 September 2012 at 19:03:03 UTC, Andrej Mitrovic wrote: On 9/4/12, Zhenya zh...@list.ru wrote: immutable char[] texture = import(Chrysanthemum.jpg); Works for me on win32 DMD2.060 and with -J. switch. Which system

Re: import doesn't import jpg

2012-09-04 Thread Zhenya
On Tuesday, 4 September 2012 at 19:03:03 UTC, Andrej Mitrovic wrote: On 9/4/12, Zhenya zh...@list.ru wrote: immutable char[] texture = import(Chrysanthemum.jpg); Works for me on win32 DMD2.060 and with -J. switch. Which system/compiler are you using? DMD 2.060 Win32 with -J switch too

Re: import doesn't import jpg

2012-09-04 Thread Zhenya
On Tuesday, 4 September 2012 at 19:38:08 UTC, Andrej Mitrovic wrote: On 9/4/12, Zhenya zh...@list.ru wrote: -J Chrysanthemium.jpg That's the issue. -J needs to be followed by a path, e.g. -J. (notice the dot), or -JC:\some\folder, and no spaces so don't use -J C:\some\folder. Remember

DerelictGL program draw nothing

2012-09-03 Thread Zhenya
Why this simple program don't show white square? import std.stdio; import derelict.opengl3.gl; import derelict.glfw3.glfw3; const uint width = 200; const uint height = 200; void init() { glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity();

Re: DerelictGL program draw nothing

2012-09-03 Thread Zhenya
On Monday, 3 September 2012 at 16:57:08 UTC, cal wrote: On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote: Why this simple program don't show white square? void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2d(0,0

Re: DerelictGL program draw nothing

2012-09-03 Thread Zhenya
On Monday, 3 September 2012 at 17:12:04 UTC, cal wrote: On Monday, 3 September 2012 at 17:08:55 UTC, cal wrote: On Monday, 3 September 2012 at 17:02:46 UTC, Zhenya wrote: that dosn't work How large is your window? glViewport(0,0,width,height); should really be setting to the window size

Re: DerelictGL program draw nothing

2012-09-03 Thread Zhenya
On Monday, 3 September 2012 at 18:47:25 UTC, Ivan Agafonov wrote: On Monday, 3 September 2012 at 15:21:59 UTC, Zhenya wrote: Why this simple program don't show white square? import std.stdio; import derelict.opengl3.gl; import derelict.glfw3.glfw3; const uint width = 200; const uint height

Derelict3+SFML2

2012-09-01 Thread Zhenya
Hello, I've got a little problem with DerelictSFML2. Despite the fact that I downloaded from the official website binaries CSFML2, this little application closes with the message: Failed to load symbol sfWindow_setSize from shared library csfml-window-2.dll module main; import std.stdio;

Re: Derelict3+SFML2

2012-09-01 Thread Zhenya
On Saturday, 1 September 2012 at 19:59:33 UTC, cal wrote: On Saturday, 1 September 2012 at 15:53:20 UTC, Zhenya wrote: Hello, I've got a little problem with DerelictSFML2. Despite the fact that I downloaded from the official website binaries CSFML2, this little application closes

Why __traits(compile,...) fails here?

2012-08-07 Thread Zhenya
import std.stdio; template isType(alias s) { enum isType = !__traits(compiles,mixin(typeof(s))); } void main() { // writeln(isType!int);// Error: template instance isType!(int) isType!(int) does not match template declaration isType(alias s)

Re: Why __traits(compile,...) fails here?

2012-08-07 Thread Zhenya
On Tuesday, 7 August 2012 at 09:47:58 UTC, Artur Skawina wrote: On 08/07/12 09:51, Zhenya wrote: import std.stdio; template isType(alias s) { enum isType = !__traits(compiles,mixin(typeof(s))); } void main() { //writeln(isType!int);// Error: template instance isType!(int) isType!(int

how to pass a variable name in the template in this case?

2012-08-02 Thread Zhenya
module main; import std.stdio; immutable double f = 0; template T(alias a) { auto T = a; } int main(string[] argv) { char f = 'a'; writeln(typeid(T!f));//deduce f as 'a' readln(); return 0; }

Re: how to pass a variable name in the template in this case?

2012-08-02 Thread Zhenya
On Thursday, 2 August 2012 at 22:36:34 UTC, Andrej Mitrovic wrote: On 8/3/12, Zhenya zh...@list.ru wrote: snip You mean how to extract the variable name? import std.stdio; template T(alias a) { enum string T = __traits(identifier, a); } void main(string[] argv) { char f

Re: how to pass a variable name in the template in this case?

2012-08-02 Thread Zhenya
Sorry for my terrible english

Re: how to pass a variable name in the template in this case?

2012-08-02 Thread Zhenya
I mean that in ths code double f = 0; template T(alias a) { void doit() { a = 1; } } int main(string[] argv) { T!f.doit(); writeln(f);//alias a is'nt 0,alias a is f readln(); return 0; } So why if we declared variable

Re: how to pass a variable name in the template in this case?

2012-08-02 Thread Zhenya
Thank you,guys,now all became clear to me.

  1   2   >