Overloading based on attributes - is it a good idea?

Jonathan Marler johnnymarler at gmail.com
Wed May 29 14:56:55 UTC 2019


On Wednesday, 29 May 2019 at 12:39:16 UTC, aliak wrote:
> On Wednesday, 29 May 2019 at 02:45:37 UTC, Jonathan Marler 
> wrote:
>> On Wednesday, 29 May 2019 at 01:14:04 UTC, Walter Bright wrote:
>>> [...]
>>
>> Well, I didn't propose an algorithm.  I was just providing a 
>> visual aid to your graph analogy. My suggesion has nothing to 
>> do with attribute inference on templates.  If it did then you 
>> are completely right that this would be a combinatorial 
>> explosion.  The idea is actually pretty "dumb" at its core.  
>> What's the simplest way to pass this information to a template?
>>  Just add a template parameter.
>>
>> [...]
>
> Doesn't Jai do something similar to this? I.e. it passes in the 
> "context" of the caller so that you can alter your code on what 
> the environment is outside the function. So the context would 
> could be a struct
>
> struct Conctext {
>   bool isNogc; bool isSafe; // etc...
> }
>
> It's be akin to introducing the concept of a "compile time 
> this" isn't it?

Yes, last time I heard Jai was using sort of an implicit runtime  
parameter.  However, I'm far from convinced it's a good idea at 
runtime .

With implicit template parameters, they would only affect the 
template if they were used, so you only pay for it if you are 
using it.  Not so with implicit runtime parameters.



More information about the Digitalmars-d mailing list