pointer to std.algorithm.iteration : splitter

2023-08-30 Thread Vino via Digitalmars-d-learn

Hi All,

  Request your help on the below error

Program
```
void main()
{
import std.stdio:writeln;
import std.algorithm.iteration : splitter;

auto splitter_ptr = &splitter!((a, b) => a.splitter(b).array);
string str = "TEST1;TEST2;TEST3";
auto words = splitter_ptr(str, ';');
foreach (word; words) { writeln(word); }
}
```
```
Error: template instance `splitter!((a, b) => 
a.splitter(b).array)` does not match any template declaration

```

From,
Vino


Re: Function Pointer

2023-08-30 Thread Paul Backus via Digitalmars-d-learn

On Wednesday, 30 August 2023 at 17:48:19 UTC, Vino wrote:

Hi All,

 Request your help on hot to create a pointer for a function 
whose function type is Result.


```
ReturnType!(typeof(&test)).stringof; // Result

From
Vino
```


To get a function pointer type from a function type, you can add 
`*` on the end:


void func(int) {}

alias FuncType = typeof(func);
pragma(msg, FuncType); // void(int)

alias FuncPtrType = FuncType*;
pragma(msg, FuncPtrType); // void function(int)
static assert(is(FuncPtrType == typeof(&func)));


Re: Pointer to environment.get

2023-08-30 Thread Vino via Digitalmars-d-learn

On Monday, 28 August 2023 at 10:27:07 UTC, Basile B. wrote:

On Monday, 28 August 2023 at 10:20:14 UTC, Basile B. wrote:

[...]


To go further, the correct code for syntax you wanted to use is 
actually


```d
alias Ext_T = string (const char[] a, string b); // define a 
function type

alias Ext_PT = Ext_T*; // define a function **pointer** type
Ext_PT ext = &environment.get;
```

But as you can see that does not allow to capture the argument. 
Also it only work as AliasDeclaration RHS.


Thank you


Ideas to reduce error message size?

2023-08-30 Thread Paolo Invernizzi via Digitalmars-d-learn

Hello everybody,

If a compilation error is thrown with CTFE involved, the 'called 
from here' is like:


 ```
src/api3.d(2010): Error: uncaught CTFE exception 
`object.Exception("42703: column \"system_timestamp_ms\" does not 
exist. SQL: select coalesce(count(system_timestamp_ms),0) from 
dev_samples where device_id = $1")`

src/api3.d(39):thrown from here
src/api3.d(49):called from here: 
`checkSql(Schema("public",  
src/dget/db.d(276): Error: template instance 
`api3.forgeSqlCheckerForSchema!(Schema("public", **BAZILLIONS of lines**>  error instantiating

 ```

Simple question: there's a pattern to reduce the outputted stuff 
someway? Everything is related to a single struct, `Schema`, used 
during compile time stuff.


Thank you,
Paolo