[Mono-dev] Mono.Simd API Suggestions

Jonathan Pryor jonpryor at vt.edu
Thu Nov 6 10:51:32 EST 2008


On Thu, 2008-11-06 at 12:04 -0200, Rodrigo Kumpera wrote:
> Thanks for taking some time looking at the Mono.Simd API and doing
> some suggestions but, please, do then on a more visible mailing list
> such as mono-devel.

Because I'm an idiot who saw "mono-d..." and assumed it was
mono-devel-list.  My bad...

> >Just perusing through the Mono.Simd API, and one question (and a few
> >other suggestions) occurs to me: Why the non-reliance on method
> >overloading?
>...
> It's a mater of choosing between "a.UnpackLow (b)" "Vector2l.UnpackLow
> (a,b)" and "VectorOperations.UnpackLow (a,b)". Feedback on this
> subject is more than welcome.

I'm not even sure what UnpackLow() does (and reading the source only
helps a little...).

Regardless, I don't like Vector2l.UnpackLow(a,b), and would prefer the
first or last options.

That said, I'm not sure which is better between static method syntax and
instance method syntax.  The advantage to instance method syntax is that
you can readily find the method through the IDE (code completion ftw!),
and should likely be preferred for that reason alone.

On the other hand, an instance method _may_ imply that the instance
variable will be modified by the method call, which is not the case
for .UnpackLow().  (Then again, this implication is already bogus; see
System.String instance methods...)

So for usability/findability, I'd suggest the instance method syntax
(even if it's really done via extension methods).

> Only a small part of the operations are available for all types and
> some are  under different instruction sets. This should be enough to
> make it pretty confusing for the user.

I'm not sure about that, but it is something to keep in mind.  So the
question remains, which is easier for the user to understand:

  - instance methods, documented in the relevant type.
    Pro: You know which operations are available specifically for a 
         given type.
    Con: You can't easily see which other types support the same 
         operation.  This may not be relevant at all; I don't know.

  - Static methods on a e.g. VectorOperations type.
    Pro: You can easily determine which operations are available across
         numerous types.
    Con: You can't tell from the type's documentation which operations
         are supported.

  - Extension methods.
    Pro: Methods are referenced from the type documentation and, since
         extension methods can be in the same extension class, they can
         also be listed as overloads.  This easily allows determining
         which operations are common across types AND which operations
         are supported on a specific type from that type's 
         documentation.
    Con: Requires C# 3.0.  (Is this really a con?)

>From that breakdown, it looks like extension methods are best. :-)

> >On a completely different note (and to start a bikeshed discussion ;-),
> >why "ShiftRightLogic"?  Wouldn't "LogicalRightShift" be more
> >conventional?  We should also avoid abbreviations, so
> ...
> OTOH, on some cases this might lead to some very very long method names.

Even vim supports code completion [0], so I don't consider this to be a
significant problem...

 - Jon

[0] Ctrl+N/Ctrl+P will complete words already present within the current
buffer and also use any words found in a `ctags` file, if available.




More information about the Mono-devel-list mailing list