Boost logo

Proto :

Subject: Re: [proto] Proto domains shenanigans
From: Eric Niebler (eric_at_[hidden])
Date: 2010-10-13 16:54:03


On 10/13/2010 11:38 AM, joel falcou wrote:
> OK, I have a situation in which proto domain/subdomain could help me but
> i can't
> wrap my head around a proper solution. Here is the deal, i have various
> sub EDSL that goes like:
>
> - constants EDSL provides named consatnts (like zero_, one_, pi_ etc)
> that are meant to be terminal
> usable in any other EDSL en provide a type based way to know which
> constant is beging used and
> provide optimization in came it helps (e.g detecting x < zero_ in SIMD
> EDSL to replace with the
> SSSE3 corresponding fused operation)
>
> - a SIMD vector EDSL
>
> - various container based EDSL : table (multidim array), vector, matrix
> and tensor, polynom and rigid_transform.
>
> The rules I want to have is :
>
> - constant can mix with any other EDSL

Make them terminals in no particular domain (proto::default_domain).

> - SIMD don't mix with anybody

Define a SIMD domain with no super-domain.

> - table mix with every other container and make them evaluates as table
> (e.g matrix * table == elementwise product and not matrix product)
> - vector, matrix, tensor can mix
> - polynom can mix with table but not with vector, matrix, tensor
> - rigid_transform van mix with table and matrix

This sounds like you want a type system for an EDSL. Proto can't do that
in its current incarnation. The hackish solution is to let everything
combine with everything, capture the above rules in a Proto grammar and
assert at the point of expression evaluation that the expression
conforms to the grammar. Type-checking sub-expressions sometimes
requires writing transforms. It's tricky.

Does that help?

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Proto list run by eric at boostpro.com