[swift-evolution] [Proposal]: Rectangles and other common structures.

Andrew Bennett cacoyi at gmail.com
Thu Jan 7 06:12:38 CST 2016


I definitely think a library for generic CG compatible types would be
great. I also think the standard library may need adaptation to allow
integers and floats to be used in generic structures (there isn't common
protocols for arithmetic operators, and those operators have different
implications for signed vs unsigned, float versus integer, etc.).

However I do not think they are fundamental enough as data structures and
data types to be in the standard library.

-1

I would support something like CGVector (for 1,2,4,8... components), if
that can expose hardware vector optimisations that may not otherwise be
accessible. However that may be implemented efficiently enough with a third
party c library (like this https://github.com/mattt/Surge), and afaik may
already be under consideration for the built-in Float types.


On Thu, Jan 7, 2016 at 6:54 PM, Charles Constant via swift-evolution <
swift-evolution at swift.org> wrote:

> > CGRectIntegral
>
> But that's conversion though, right? That's part of what I find
> stressful. If I'm using Ints internally, I don't ever need to worry about
> getting wonky results because of floating point math.
>
> On Wed, Jan 6, 2016 at 11:45 PM, John Randolph <jcr at icloud.com> wrote:
>
>>
>> > On Jan 6, 2016, at 11:38 PM, Charles Constant <charles at charlesism.com>
>> wrote:
>> >
>> > > I can certainly think of situations where I might want integer based
>> rectangles, sizes, and points.
>> >
>> > I'm quite biased this week, because I spent *yesterday* writing a file
>> for my project with "IntRect" "IntPoint" "IntSize" ad nauseam. It's not
>> something I'm very thrilled to have as part of my Audio app - a lone file
>> of geometric structs that aready exist if you use CGFloats, where I don't
>> get the full implementation, etc. And previously, I've written code that I
>> needed land on whole numbers, and the extra concern about finding the right
>> options in Cocoa to do so just stressed me out.
>>
>> FWIW, NSIntegralRect() and CGRectIntegral() do exist.  Note their
>> entirely different naming conventions.  ;-)
>>
>> Would be much nicer to just use myRect.integralRect when I need to round
>> it.  Might also be nice to have myRect.roundedOut and myRect.roundedIn for
>> a bit more control of which way the sides move.
>>
>> -jcr
>>
>>
>>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160107/bd18721c/attachment.html>


More information about the swift-evolution mailing list