• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: swift and objective-c
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: swift and objective-c
      • From: Scott Ribe <email@hidden>
References: 
 >swift and objective-c (From: "McLaughlin, Michael P." <email@hidden>)
 >Re: swift and objective-c (From: Roland King <email@hidden>)
 >Re: swift and objective-c (From: Ron Hunsinger <email@hidden>)
 >Re: swift and objective-c (From: Jeremy Pereira <email@hidden>)
 >Re: swift and objective-c (From: Scott Ribe <email@hidden>)
 >Re: swift and objective-c (From: Jeremy Pereira <email@hidden>)
 >Re: swift and objective-c (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: swift and objective-c
  • Next by Date: Re: swift and objective-c
  • Previous by thread: Re: swift and objective-c
  • Next by thread: Re: swift and objective-c
  • Index(es):
    • Date
    • Thread