Re: Phobos: __FILE__ as template default parameter

2016-07-05 Thread Johan Engelen via Digitalmars-d
On Monday, 20 June 2016 at 08:10:19 UTC, Dicebot wrote: How about defining semantics like "try inlining if possible, fallback to always emitting symbol to object file otherwise"? That would also allow compatible implementation in dmd. My reasoning for proposing that is that for all

Re: Phobos: __FILE__ as template default parameter

2016-06-22 Thread Johan Engelen via Digitalmars-d
On Tuesday, 21 June 2016 at 10:39:52 UTC, David Nadlinger wrote: On Monday, 20 June 2016 at 08:10:19 UTC, Dicebot wrote: How about defining semantics like "try inlining if possible, fallback to always emitting symbol to object file otherwise"? That would also allow compatible implementation in

Re: Phobos: __FILE__ as template default parameter

2016-06-21 Thread ZombineDev via Digitalmars-d
On Tuesday, 21 June 2016 at 10:34:01 UTC, pineapple wrote: On Tuesday, 21 June 2016 at 10:28:03 UTC, pineapple wrote: On Tuesday, 21 June 2016 at 02:59:44 UTC, ZombineDev wrote: I think it would be good idea to take this even further: T4 foo(T4, T0, T1, Ts..., T2, T3)(T0 t0, T1 t1, Args args,

Re: Phobos: __FILE__ as template default parameter

2016-06-21 Thread David Nadlinger via Digitalmars-d
On Monday, 20 June 2016 at 08:10:19 UTC, Dicebot wrote: How about defining semantics like "try inlining if possible, fallback to always emitting symbol to object file otherwise"? That would also allow compatible implementation in dmd. This would get rid of the undefined symbols, but there is

Re: Phobos: __FILE__ as template default parameter

2016-06-21 Thread pineapple via Digitalmars-d
On Tuesday, 21 June 2016 at 10:28:03 UTC, pineapple wrote: On Tuesday, 21 June 2016 at 02:59:44 UTC, ZombineDev wrote: I think it would be good idea to take this even further: T4 foo(T4, T0, T1, Ts..., T2, T3)(T0 t0, T1 t1, Args args, T2 t2, T3 t3) In other words, I think that the

Re: Phobos: __FILE__ as template default parameter

2016-06-21 Thread pineapple via Digitalmars-d
On Tuesday, 21 June 2016 at 02:59:44 UTC, ZombineDev wrote: I think it would be good idea to take this even further: T4 foo(T4, T0, T1, Ts..., T2, T3)(T0 t0, T1 t1, Args args, T2 t2, T3 t3) In other words, I think that the limitation that variadic template parameter list must be at the end

Re: Phobos: __FILE__ as template default parameter

2016-06-20 Thread ZombineDev via Digitalmars-d
On Tuesday, 21 June 2016 at 02:59:44 UTC, ZombineDev wrote: On Monday, 20 June 2016 at 14:28:06 UTC, Jacob Carlborg wrote: On 2016-06-19 12:43, Dicebot wrote: Yes. It is necessary because runtime parameter list is variadic - template bloat in such cases is usually eliminated by forwarding to

Re: Phobos: __FILE__ as template default parameter

2016-06-20 Thread ZombineDev via Digitalmars-d
On Monday, 20 June 2016 at 14:28:06 UTC, Jacob Carlborg wrote: On 2016-06-19 12:43, Dicebot wrote: Yes. It is necessary because runtime parameter list is variadic - template bloat in such cases is usually eliminated by forwarding to another private method immediately turning file/line into

Re: Phobos: __FILE__ as template default parameter

2016-06-20 Thread Simen Kjaeraas via Digitalmars-d
On Monday, 20 June 2016 at 14:28:06 UTC, Jacob Carlborg wrote: Would it be a bad idea to allow this in the compiler: void foo(Args...)(Args args, string file = __FILE__, size_t line = __LINE__); It wouldn't be possible to pass "file" or "line" when calling "foo". But it's useful for the

Re: Phobos: __FILE__ as template default parameter

2016-06-20 Thread Jacob Carlborg via Digitalmars-d
On 2016-06-19 12:43, Dicebot wrote: Yes. It is necessary because runtime parameter list is variadic - template bloat in such cases is usually eliminated by forwarding to another private method immediately turning file/line into first runtime argument instead. Would it be a bad idea to allow

Re: Phobos: __FILE__ as template default parameter

2016-06-20 Thread Dicebot via Digitalmars-d
On 06/20/2016 01:13 AM, Johan Engelen wrote: > On Sunday, 19 June 2016 at 21:40:20 UTC, David Nadlinger wrote: >> On Sunday, 19 June 2016 at 21:13:00 UTC, Johan Engelen wrote: >>> On Sunday, 19 June 2016 at 21:11:59 UTC, Johan Engelen wrote: (I think we can pretty much inline anything the

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Lass Safin via Digitalmars-d
On Saturday, 18 June 2016 at 18:13:22 UTC, Johan Engelen wrote: An example of how __FILE__ as template parameter will break your library: In library, distributed in binary+source form: ``` alias file_templ_alias = file_templ!bool; T file_templ(T, string file = __FILE__, size_t line = __LINE__)

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Johan Engelen via Digitalmars-d
On Sunday, 19 June 2016 at 21:40:20 UTC, David Nadlinger wrote: On Sunday, 19 June 2016 at 21:13:00 UTC, Johan Engelen wrote: On Sunday, 19 June 2016 at 21:11:59 UTC, Johan Engelen wrote: (I think we can pretty much inline anything the user throws at us) (as long as it is not a naked asm

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread David Nadlinger via Digitalmars-d
On Sunday, 19 June 2016 at 21:13:00 UTC, Johan Engelen wrote: On Sunday, 19 June 2016 at 21:11:59 UTC, Johan Engelen wrote: (I think we can pretty much inline anything the user throws at us) (as long as it is not a naked asm function) Another example is `alloca`, which you might not want to

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Johan Engelen via Digitalmars-d
On Sunday, 19 June 2016 at 21:11:59 UTC, Johan Engelen wrote: (I think we can pretty much inline anything the user throws at us) (as long as it is not a naked asm function)

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Johan Engelen via Digitalmars-d
On Sunday, 19 June 2016 at 20:37:02 UTC, Dicebot wrote: On 06/19/2016 11:33 AM, Johan Engelen wrote: On Sunday, 19 June 2016 at 08:06:09 UTC, Dicebot wrote: This important feature and can't be simply removed. For example, std.experimental.logger also relies on it. Do you mean it relies on

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Dicebot via Digitalmars-d
On 06/19/2016 11:33 AM, Johan Engelen wrote: > On Sunday, 19 June 2016 at 08:06:09 UTC, Dicebot wrote: >> This important feature and can't be simply removed. For example, >> std.experimental.logger also relies on it. > > Do you mean it relies on __FILE__ being a template parameter (instead of > a

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Dicebot via Digitalmars-d
On Sunday, 19 June 2016 at 08:33:40 UTC, Johan Engelen wrote: On Sunday, 19 June 2016 at 08:06:09 UTC, Dicebot wrote: This important feature and can't be simply removed. For example, std.experimental.logger also relies on it. Do you mean it relies on __FILE__ being a template parameter

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Johan Engelen via Digitalmars-d
On Sunday, 19 June 2016 at 08:06:09 UTC, Dicebot wrote: This important feature and can't be simply removed. For example, std.experimental.logger also relies on it. Do you mean it relies on __FILE__ being a template parameter (instead of a runtime default parameter, like enforce)? It needs

Re: Phobos: __FILE__ as template default parameter

2016-06-19 Thread Dicebot via Digitalmars-d
This important feature and can't be simply removed. For example, std.experimental.logger also relies on it. It needs to be fixed instead. Two immediate workarounds that come to mmy mind: 1. Make __FILE__ relative to import path 2. Always emit new symbol to object file if __FILE__ is involved

Re: Phobos: __FILE__ as template default parameter

2016-06-18 Thread Johan Engelen via Digitalmars-d
An example of how __FILE__ as template parameter will break your library: In library, distributed in binary+source form: ``` alias file_templ_alias = file_templ!bool; T file_templ(T, string file = __FILE__, size_t line = __LINE__) (T value) { return value; } ``` In user code, linking to