isCallable fails

Paul Backus snarwin at gmail.com
Wed Jan 20 21:57:59 UTC 2021


On Wednesday, 20 January 2021 at 19:01:19 UTC, frame wrote:
> On Wednesday, 20 January 2021 at 13:11:09 UTC, Paul Backus
>>
>> Please post an example with enough code to actually produce 
>> the error you're seeing.
>
> I don't know when to stop posting code then :(

You should stop (and ideally start) with a Minimal, Complete, 
Verifiable Example:

https://idownvotedbecau.se/nomcve/

Just to illustrate why this matters, let me walk you through the 
steps it takes me to try and figure out what your issue is from 
just the posts you've made so far.

---

Step 1: go through each of your posts and copy each of the 
individual code snippets into a run.dlang.io window.

Result: https://run.dlang.io/is/nidfug

This code compiles--because it's all templates, and you haven't 
actually provided any example of the code that *uses* these 
templates.

---

Step 2: look at the comments and try to guess what the usage code 
must look like.

Result: https://run.dlang.io/is/P7Pcr1

First, we need to define a class with a member named `data` to 
pass as an argument to something. And data's type has to be 
`foo!bar`, so we need a type named `bar` to use for that.

What kind of type? Well, if we look at how `bar` is used in 
`foo`, we can see that it's compared with `null`, so we know it's 
a reference type--probably a class.

Now we can finally attempt to instantiate `something`. What 
happens when we do?

     Error: template instance loadAllMatched!TDobj template 
loadAllMatched is not defined

Great, another piece of missing code.

---

Step 3: try to stub out loadAllMatched.

Result: https://run.dlang.io/is/uRj6HW

     Error: template instance `isCallable!S` template `isCallable` 
is not defined

Siiiiigh.

---

Step 4: add the missing import.

Result: https://run.dlang.io/is/2by7sU

Oh, look, it compiles with no errors. All that effort, and I 
*still* couldn't reproduce the issue you described in your 
original post. Guess I wasted my time for nothing!


More information about the Digitalmars-d-learn mailing list