Re: swift and objective-c
Re: swift and objective-c
- Subject: Re: swift and objective-c
- From: Jeremy Pereira <email@hidden>
- Date: Thu, 05 Jun 2014 10:04:15 +0100
On 4 Jun 2014, at 17:14, Scott Ribe <email@hidden> wrote:
> On Jun 4, 2014, at 9:51 AM, Jeremy Pereira <email@hidden> wrote:
>
>> You need to think about that definition again. It's nonsense if y is negative.
>
> No, it is not, and it is the correct definition.
Yes it is. your definition is
"The modulo operation is precisely defined, x mod y results in a positive integer between 0 and y - 1"
If I set y to -3, the definition becomes
"The modulo operation is precisely defined, x mod -3 results in a positive integer between 0 and -4"
That is clearly nonsense.
>
>> Agreed, but neither Swift nor C99 call the % operator "modulo"...
>
> But C did call the % operator "modulus" for a very long time, which led to a lot of this confusion.
I agree, according to the Wikipedia page, C89 made the result of the % operator implementation defined, which is a train crash waiting to happen. However, as I said, C99 (15 years old) precisely defines the operation (and calls it "remainder"). It defines the operation that way to make it compatible with a truncate towards zero integer division operator, which many people would regard as more intuitive.
I agree with you that the proper definition should have been the right way to go, but Swift follows a convention that has been in place in programming for many years.
>
> --
> Scott Ribe
> email@hidden
> http://www.elevated-dev.com/
> (303) 722-0567 voice
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden