Here's what I'm talking about:
I know that I can currently create a function template which takes in a 
function as a parameter, which can be observed below:
fn{a:vt@ype} map_test ( t: &test, mapper: a -<cloref1> void ) : void

But, let's say that the 'test' typedef is as follows:
vtypedef test = [a:vt@ype] ( a )

In this instance, the function 'map_test()' will not work for the type 
'test' because the passed mapping function 'mapper' may not necessarily 
take in the correct type (the 'test' type essentially hides the type it 
contains.)  Of course, 'test' could be rewritten to take in a type, 
allowing the type checker to verify that the type within 'test' matches.  
Doing so would look like this:
vtypedef test(a:vt@ype) = ( a ) 

But, what if I want the type within 'test' to remain hidden?  If 'mapper,' 
instead of being a function, was a template, then it would compile (given 
said template had the proper implementations.)  Essentially, instead of me 
wanting to verify that 'mapper' will take in the given vt@ype 'a', I want 
'mapper' to reference a function template which then will be specifically 
implemented for any needed types.  Then, I could create a generic map 
function template that would work on a type which hides its contained 
generic type.  I'll admit, this is a pretty niche use case, but I wanted to 
know whether I could indeed do this.

I've already found a way to work around this via the use of local template 
instantiation, which may be the better way to handle things anyways.

Please let me know if this example is insufficient.
On Saturday, January 2, 2021 at 9:59:20 PM UTC-5 gmhwxi wrote:

> Yes, I would like to see an example of this kind.
>
>
> On Sat, Jan 2, 2021 at 9:19 PM d4v3y_5c0n3s <tmj...@gmail.com> wrote:
>
>> So, I know that  it's possible to pass a function to another function as 
>> a parameter, but what if I want to pass a function template specifically?  
>> If anyone would like some clarification, I can try to provide some examples 
>> of what I'm trying to achieve. 
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "ats-lang-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to ats-lang-user...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ats-lang-users/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ats-lang-users/96fc4ec0-8355-4b32-883a-30f2293b4861n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ats-lang-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ats-lang-users/33bcc99a-936f-49d9-9ec6-6ec57ca4d15an%40googlegroups.com.

Reply via email to