Attributes could also be applied to anonymous functions, e.g. (using 'fn'
instead of 'lambda'):

  f = fn[Fortran] (x:double) { x**2 - 2.0 }
  root = legacy_fortran_find_root_function(x_lb, x_ub, f)

(As you might guess I use Fortran a lot.)

Come to think of it, we should probably think about the syntax for variable
type attributes too. Suppose I wanted an array to be stored in GPU memory?

  x = Array<float32>[gpu](10)
  gpu_kernel = fn[gpu] (x) { /* do stuff with x to get y */; y }
  y = gpu_kernel(x)

Or something to that effect. See

http://www.pgroup.com/lit/articles/insider/v1n3a2.htm


Chris

On Wed, Aug 11, 2010 at 11:24 AM, Christopher Gilbreth <cngilbr...@gmail.com
> wrote:

> On Tue, Aug 10, 2010 at 7:01 PM, Jonathan S. Shapiro <s...@eros-os.org>wrote:
>
>> The full production for function types is:
>>
>>    fntype: [effects] fn ( argType [, argType]* ) -> resultType
>>
>
> I wonder if the function type syntax should allow for other attributes
> which may be added in the future, e.g. calling conventions, or to declare
> that a function is executed on a gpu (in some compiler-dependent way):
>
> f : fn 'a -> 'b
> f : fn[fastcall] 'a -> 'b
> f : fn[Fortran,some_other_attribute] 'a -> 'b
> f : fn[gpu] 'a -> 'b
>
> (Are the brackets of any actual benefit in these examples?)
>
> See also
>
> http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
>
>
> Chris
>
_______________________________________________
bitc-dev mailing list
bitc-dev@coyotos.org
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to