Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Integer Division and Modulo as a single operator?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 50 of 61 - Collapse all  -  Translate all to Translated (View all originals) < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ajventi  
View profile  
 More options Mar 25 2012, 8:23 am
From: ajventi <ajve...@gmail.com>
Date: Sun, 25 Mar 2012 05:23:35 -0700 (PDT)
Local: Sun, Mar 25 2012 8:23 am
Subject: Re: Integer Division and Modulo as a single operator?
Well since I guess this was a proposal of sorts let me modify and
clarify somewhat.

Quick summary:

1. Add a binary operator or function that returns both the quotient
and modulo.
    I propose /% as an operator, otherwise math.Divmod(a, b int) (q, m
int)

2. Is there any reason to require we assign multiple values? Why not
simply allow us to ignore a second result rather than force us to use
`_'

 I hadn't realized that a map reference didn't require the second
value to be assigned. It's a strange inconsistency, but I'd rather
that become the standard rather than the underscore. If I want to
ignore something, and the language allows me to ignore it, why should
I have to tell the compiler "I'm ignoring that"

I should also point out that in LISP the TRUNCATE function is what
returns Quotient and Modulo. The / function in Lisp is a generic, if
you call it with two integers it returns a fraction.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Liigo Zhuang  
View profile  
 More options Mar 25 2012, 8:43 am
From: Liigo Zhuang <com.li...@gmail.com>
Date: Sun, 25 Mar 2012 20:43:04 +0800
Local: Sun, Mar 25 2012 8:43 am
Subject: Re: [go-nuts] Re: Integer Division and Modulo as a single operator?

+1
在 2012-3-25 下午8:23,"ajventi" <ajve...@gmail.com>写道:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rémy Oudompheng  
View profile  
 More options Mar 25 2012, 8:49 am
From: Rémy Oudompheng <remyoudomph...@gmail.com>
Date: Sun, 25 Mar 2012 14:49:53 +0200
Local: Sun, Mar 25 2012 8:49 am
Subject: Re: [go-nuts] Re: Integer Division and Modulo as a single operator?
Le 25 mars 2012 14:23, ajventi <ajve...@gmail.com> a écrit :

> Well since I guess this was a proposal of sorts let me modify and
> clarify somewhat.

> Quick summary:

> 1. Add a binary operator or function that returns both the quotient
> and modulo.
>    I propose /% as an operator, otherwise math.Divmod(a, b int) (q, m
> int)

In what kind of programs do you expect to use that?

> 2. Is there any reason to require we assign multiple values? Why not
> simply allow us to ignore a second result rather than force us to use
> `_'

I'm not sure what is the use for a new magic operator if you are going
to ignore return values.

Rémy.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
si guy  
View profile  
 More options Mar 25 2012, 11:18 am
From: si guy <sjw...@gmail.com>
Date: Sun, 25 Mar 2012 08:18:12 -0700 (PDT)
Local: Sun, Mar 25 2012 11:18 am
Subject: Re: [go-nuts] Re: Integer Division and Modulo as a single operator?

I use this kind of operation all of the time for getting I,j,k,....,m coordinates in an n-dimensional array that is stored in a one-dimensional array (or slice).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ziutek  
View profile  
 More options Mar 25 2012, 4:32 pm
From: ziutek <ziu...@Lnet.pl>
Date: Sun, 25 Mar 2012 13:32:26 -0700 (PDT)
Local: Sun, Mar 25 2012 4:32 pm
Subject: Re: Integer Division and Modulo as a single operator?

> 1. Add a binary operator or function that returns both the quotient
> and modulo.
>     I propose /% as an operator, otherwise math.Divmod(a, b int) (q, m
> int)

> 2. Is there any reason to require we assign multiple values? Why not
> simply allow us to ignore a second result rather than force us to use
> `_'

What about this:

c, d := a + b, a /% b
 c, d, r := a + b, a /% b

It seems to be a little confusing to me.

I think that it will be sufficient if the compiler specification will
guarantee that:

 d, r := a / b, a % b

will be optimized on platforms that perform such operation using one
machine instruction.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rémy Oudompheng  
View profile  
 More options Mar 25 2012, 4:34 pm
From: Rémy Oudompheng <remyoudomph...@gmail.com>
Date: Sun, 25 Mar 2012 22:34:25 +0200
Local: Sun, Mar 25 2012 4:34 pm
Subject: Re: Integer Division and Modulo as a single operator?
Le 25 mars 2012 21:43, ajventi <ajve...@gmail.com> a écrit :

>> In what kind of programs do you expect to use that?

> Really? Have you ever wondered what sort of magic it takes to convert
> an integer into a string?

Yes, I have. And there's already a package doing that. It can be
optimized and expanded. My question is more about real world programs
that would have a clear benefit out of "q, r := a /% b" vs. "q, r :=
a/b, a%b".

I just don't see an added value for a new operator from the discussion
(as opposed to the detection of overflow, which I think would be
valuable). I think that /% is not really readable, and I can't think
of a symbol that looks readable. Also I don't think performance
matters as a criterion to decide what a language should look like,
except maybe, for the overall design, but not at that level of detail.

And about performance, I'd like to know if performance would be
improved by adding that operator and mapping it to the corresponding
instruction. Do you have benchmarks?

Rémy.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Job van der Zwan  
View profile  
 More options Mar 26 2012, 2:45 am
From: Job van der Zwan <j.l.vanderz...@gmail.com>
Date: Sun, 25 Mar 2012 23:45:45 -0700 (PDT)
Local: Mon, Mar 26 2012 2:45 am
Subject: Re: Integer Division and Modulo as a single operator?

On Sunday, 25 March 2012 22:34:25 UTC+2, Rémy Oudompheng wrote:

> And about performance, I'd like to know if performance would be
> improved by adding that operator and mapping it to the corresponding
> instruction. Do you have benchmarks?

I'm not sure how you would benchmark that, short of

- writing a simple program where this proposal would simplify the code
- disassembling it
- rewriting the relevant parts of it in assembler by hand


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Liigo Zhuang  
View profile  
 More options Mar 26 2012, 4:46 am
From: Liigo Zhuang <com.li...@gmail.com>
Date: Mon, 26 Mar 2012 16:46:20 +0800
Local: Mon, Mar 26 2012 4:46 am
Subject: Re: [go-nuts] Re: Integer Division and Modulo as a single operator?

在 2012-3-26 上午4:32,"ziutek" <ziu...@lnet.pl>写道:

+1
The easiest way to do it currently.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Geisler  
View profile  
 More options Mar 26 2012, 8:22 am
From: Martin Geisler <m...@aragost.com>
Date: Mon, 26 Mar 2012 14:22:01 +0200
Local: Mon, Mar 26 2012 8:22 am
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

andrey mirtchovski <mirtchov...@gmail.com> writes:
>> As a new user it feels inconsistent. Not broken and not something you
>> cannot get used to, but the inconsistencies stand out.

> One of the nice things Go has got going for it, in my opinion: the
> inconsistencies are in-your-face when you start using it, but they're
> a relatively small number (you've pretty much enumerated them all,
> leaving one or two gotchas having to do with closures or goroutines
> that catch newcomers). It's a set that one can definitely keep track
> of in their head and quickly get accustomed to if they write Go code
> primarily.

Thanks, that is a another good point that I hadn't considered :)

--
Martin Geisler

aragost Trifork
Professional Mercurial support
http://www.aragost.com/mercurial/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Geisler  
View profile  
 More options Mar 26 2012, 8:20 am
From: Martin Geisler <m...@aragost.com>
Date: Mon, 26 Mar 2012 14:20:33 +0200
Local: Mon, Mar 26 2012 8:20 am
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

John Asmuth <jasm...@gmail.com> writes:
> On Saturday, March 24, 2012 3:16:31 PM UTC-4, Martin Geisler wrote:

>> This is just a brain-dump after playing with Go for some weeks. As a
>> new user it feels inconsistent. Not broken and not something you
>> cannot get used to, but the inconsistencies stand out.

> I believe it is not true that a language needs to be inconsistent.
> "Fairness" adds no benefit to anyone who isn't trying to tinker with
> and extend the language via userspace. It doesn't actually make it
> easier to write real code.

That's an interesting point and I admit that I haven't thought of it
like this before.

For me, the inconsistencies makes it (ever so slightly) harder to get a
firm mental model for the language. I'm used to Python, and there's it's
no mystery what 'range' is -- it's a function like any other. So

  for i in range(10): ...

is easy: range(10) returns a generator that I can iterate over. An
iterator is itself just an object that implements a ceratain interface.
Since it's just a normal object, I can trivially do

  seq = range(10)
  for i in seq: ...

and get the same result. With Go I cannot do

  seq := range some_array

and then iterate over the array later -- range is "magic" somehow and I
don't know what it "is". (Of course I know what it is, it's a syntax
that can be used in a for-loop to iterate over certain types. But I
somehow feel that this explanation is more opaque than in Python.)

--
Martin Geisler

aragost Trifork
Professional Mercurial support
http://www.aragost.com/mercurial/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jesse McNelis  
View profile  
 More options Mar 26 2012, 12:23 pm
From: Jesse McNelis <jes...@jessta.id.au>
Date: Tue, 27 Mar 2012 03:23:41 +1100
Local: Mon, Mar 26 2012 12:23 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

On Mon, Mar 26, 2012 at 11:20 PM, Martin Geisler <m...@aragost.com> wrote:
> I'm used to Python, and there's it's
> no mystery what 'range' is -- it's a function like any other. So

>  for i in range(10): ...

But what is 'in'?
'in' is usually a boolean operator
eg.

seq = range(10)
i = 2
a = i in seq
# a is True

But in a for loop 'in' magically also assigns to i and has a
completely different behaviour.

i = 2
for i in [1,2,3,4,5,6]:
    print(i)
    i = 20

for some reason my Boolean expression is acting in a very strange way
and the loop isn't break when i is no longer within the list.

--
=====================
http://jessta.id.au


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andrey mirtchovski  
View profile  
 More options Mar 26 2012, 12:40 pm
From: andrey mirtchovski <mirtchov...@gmail.com>
Date: Mon, 26 Mar 2012 10:40:19 -0600
Local: Mon, Mar 26 2012 12:40 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

> For me, the inconsistencies makes it (ever so slightly) harder to get a
> firm mental model for the language. I'm used to Python, and there's it's
> no mystery what 'range' is -- it's a function like any other. So

if "range" is so simple then why does python need "xrange"? what's the
difference between them? why use one instead of the other? is range
even thread-safe?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Gallant  
View profile  
 More options Mar 26 2012, 1:39 pm
From: Andrew Gallant <jams...@gmail.com>
Date: Mon, 26 Mar 2012 10:39:38 -0700 (PDT)
Local: Mon, Mar 26 2012 1:39 pm
Subject: Re: Integer Division and Modulo as a single operator?

> if "range" is so simple then why does python need "xrange"? what's the
> difference between them? why use one instead of the other? is range
> even thread-safe?

"xrange" is the generator version of "range." It's useful particularly
when the collection you're iterating over is large in size. (xrange
makes sure only one element is in memory whereas range forces all
elements to occupy memory.)

At least, that's my understanding of the difference.

- Andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kyle Lemons  
View profile  
 More options Mar 26 2012, 2:19 pm
From: Kyle Lemons <kev...@google.com>
Date: Mon, 26 Mar 2012 11:19:05 -0700
Local: Mon, Mar 26 2012 2:19 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

I've been thinking about this.  As much as

quo, rem := dd / div

looks sexy, the following does not:

quo, rem := a*b / c*d
(yes, it is deliberately incorrect)

For both clarity and distinction, I would slightly prefer the addition of
builtin add(), mul(), sub(), and div() functions with either fixed or
variadic returns.

quo, rem := div(a*b, c*d)

Michael

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John Asmuth  
View profile  
 More options Mar 26 2012, 2:28 pm
From: John Asmuth <jasm...@gmail.com>
Date: Mon, 26 Mar 2012 14:28:03 -0400
Local: Mon, Mar 26 2012 2:28 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

On Mon, Mar 26, 2012 at 2:19 PM, Kyle Lemons <kev...@google.com> wrote:

> quo, rem := a*b / c*d
> (yes, it is deliberately incorrect)

Huh - I thought have thought that times would come before divide. I guess
that only serves your point.

> For both clarity and distinction, I would slightly prefer the addition of
> builtin add(), mul(), sub(), and div() functions with either fixed or
> variadic returns.

Maybe in a package, rather than built-in?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Jones  
View profile  
 More options Mar 26 2012, 2:30 pm
From: Michael Jones <m...@google.com>
Date: Mon, 26 Mar 2012 11:30:04 -0700
Local: Mon, Mar 26 2012 2:30 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

The dual value form only makes sense for a single operation. I have
suggested it exclusively that way during the past year or more.

--
Michael T. Jones | Chief Technology Advocate  | m...@google.com |  +1
650-335-5765

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Geisler  
View profile  
 More options Mar 26 2012, 2:32 pm
From: Martin Geisler <m...@aragost.com>
Date: Mon, 26 Mar 2012 20:32:24 +0200
Local: Mon, Mar 26 2012 2:32 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

Hmm... :-) I think the crucial point was the ":=" part for me. In Go you
write

  for v := range someArray { ... }

and in Python you write

  for v in someSeq: ...

There's no assignment (=) in Python and "for <vars> in <something>" is
the syntax. The equivalent in Go is "for <vars> := range <something>".
The use of ":=" somehow looked weird to me.

> i = 2
> for i in [1,2,3,4,5,6]:
>     print(i)
>     i = 20

> for some reason my Boolean expression is acting in a very strange way
> and the loop isn't break when i is no longer within the list.

Hmm... :-) I see "for ... in" as a single construct and never thought
twice about that "in" is also a binary operator.

I get your point and I'll get used to the syntax. Thanks for the
discussion!

--
Martin Geisler

Mercurial links: http://mercurial.ch/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Shields  
View profile  
 More options Mar 26 2012, 2:36 pm
From: Michael Shields <mshie...@google.com>
Date: Mon, 26 Mar 2012 11:36:01 -0700
Local: Mon, Mar 26 2012 2:36 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

On Mon, Mar 26, 2012 at 9:40 AM, andrey mirtchovski
<mirtchov...@gmail.com>wrote:

> if "range" is so simple then why does python need "xrange"?

It doesn't, and Python 3 has only the generator range.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kyle Lemons  
View profile  
 More options Mar 26 2012, 2:37 pm
From: Kyle Lemons <kev...@google.com>
Date: Mon, 26 Mar 2012 11:37:41 -0700
Local: Mon, Mar 26 2012 2:37 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

On Mon, Mar 26, 2012 at 11:30 AM, Michael Jones <m...@google.com> wrote:
> The dual value form only makes sense for a single operation. I have
> suggested it exclusively that way during the past year or more.

Ah.  I don't think I'd seen you mention that it wouldn't be available if
there were more than a single operation, but that makes a lot of sense too.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Jones  
View profile  
 More options Mar 26 2012, 2:56 pm
From: Michael Jones <m...@google.com>
Date: Mon, 26 Mar 2012 11:56:18 -0700
Local: Mon, Mar 26 2012 2:56 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

Sorry. It certainly causes the two obvious objections:

1. What a special case! The "comma,overflow" is optional only in simple,
single expressions.
2. What a rare case! How many people ever check for overflow!

Both are true. I admit that. However, how else would one code these cases
portably? The answer is like this (for division, if there were no mod):

//want q,r := n/d, where 'n' and 'd' are arbitrary expressions.

t1 := n
t2 := d
// ...check for zero divisor here, then...
q := n/d
r := n - q*d

As it happens, this division case is by far the fastest to compute compared
to the others, and even here, compilers are not good. If you look at Go
now, you'll see that...

q := n/10
r := n%10

is 15% or so slower than

q := n/10
r := n - (q << 3 + q)

even though q and r are right there in CPU registers waiting to be use
directly. It is much worse for multiplicative overflow, where the only real
solutions involve breaking each factor into a high and low part (in BASE
bitsize/2) and evaluating (a*BASE+b)*(c*BASE+d) in stages, again, even
though the high product is right there in CPU registers waiting to be used
with a single register move or test.

Maybe a reasonable compromise would be special functions (one of my example
approaches):

s,o := SpecialAdd(a, b)
d,u := SpecialSubtract(a, b)
l,h := SpecialMultiply(a, b)
q,r := SpecialDivide(a, b)

Where the compiler agrees that whatever names are chosen are reserved and
handled inline.

--
Michael T. Jones | Chief Technology Advocate  | m...@google.com |  +1
650-335-5765

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Jones  
View profile  
 More options Mar 26 2012, 2:57 pm
From: Michael Jones <m...@google.com>
Date: Mon, 26 Mar 2012 11:57:19 -0700
Local: Mon, Mar 26 2012 2:57 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

Oops,

r := n - (q << 3 + q << 1)

On Mon, Mar 26, 2012 at 11:56 AM, Michael Jones <m...@google.com> wrote:
> r := n - (q << 3 + q)

--
Michael T. Jones | Chief Technology Advocate  | m...@google.com |  +1
650-335-5765

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Blenkinsop  
View profile  
 More options Mar 26 2012, 3:54 pm
From: Steven Blenkinsop <steven...@gmail.com>
Date: Mon, 26 Mar 2012 15:54:16 -0400
Local: Mon, Mar 26 2012 3:54 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

On Mar 26, 2012, at 2:32 PM, Martin Geisler <m...@aragost.com> wrote:

> Hmm... :-) I think the crucial point was the ":=" part for me. In Go you
> write

>  for v := range someArray { ... }

> and in Python you write

>  for v in someSeq: ...

> There's no assignment (=) in Python and "for <vars> in <something>" is
> the syntax. The equivalent in Go is "for <vars> := range <something>".
> The use of ":=" somehow looked weird to me.

I guess the way to see it is that the `range` is loop syntax that controls the loop and retrieves different values from the following expression on each iteration, like `in`, except that you then have to assign these values to variables rather than having it automatically bound to the identifier to the left of the keyword. Having the `:=` or `=` in there gives you control over declaration, which is a useful feature.

This and `switch x := v.(type)` are examples of where there's a bit of a "huh, how does that syntax compose, exactly?" moment when learning it. It isn't the obvious design. However, it is syntactically unambiguous, and in an odd kind of way suggests its intent. So it works, even if it seems odd.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Borman  
View profile  
 More options Mar 26 2012, 3:59 pm
From: Paul Borman <bor...@google.com>
Date: Mon, 26 Mar 2012 12:59:25 -0700
Local: Mon, Mar 26 2012 3:59 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

I overall agree with Michael.  I have found that expression is also much
more difficult than concept, and expression is what the lexer and parser
are all about.

I frequently need both the quotient and remainder and I am always annoyed
that I have to repeat the operation twice.

q, r := n/d, n%d

is probably worse than

q := n/d
r := n%d

and

q, r := n/d

really feels the most natural to me as a human.

I also have, not quite as frequently, had to check for carry, but it is
always a special case:

// assume a is positive
na := n + a
if na < n {
    // we overflowed

}

Note the assume comment.  For multiplication I simply give up and if
possible use double the bit width (and hope that 64 bits is always enough).

To me it seems Michael is often working with real mathematics, unlike OS
guys like me who think floating point is something for users :-)  But even
so, I see good reason to not throw away so much of what the CPU does for
us.  It is not as useless as nearly all modern languages make it appear.

For me the WHAT is "return us more complete results from CPU arithmetic
operations" and I will leave the HOW up to the Go designers.  The have done
a good job thus far!

    -Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kyle Lemons  
View profile  
 More options Mar 26 2012, 4:09 pm
From: Kyle Lemons <kev...@google.com>
Date: Mon, 26 Mar 2012 13:09:06 -0700
Local: Mon, Mar 26 2012 4:09 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

+1

I suspect that, if given the ability, many more programmers will find that
they've always wanted the feature but never known to ask for it.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Geisler  
View profile  
 More options Mar 26 2012, 2:34 pm
From: Martin Geisler <m...@aragost.com>
Date: Mon, 26 Mar 2012 20:34:12 +0200
Local: Mon, Mar 26 2012 2:34 pm
Subject: Re: [go-nuts] Integer Division and Modulo as a single operator?

andrey mirtchovski <mirtchov...@gmail.com> writes:
>> For me, the inconsistencies makes it (ever so slightly) harder to get
>> a firm mental model for the language. I'm used to Python, and there's
>> it's no mystery what 'range' is -- it's a function like any other. So

> if "range" is so simple then why does python need "xrange"? what's the
> difference between them? why use one instead of the other? is range
> even thread-safe?

It doesn't really "need" it -- xrange is just there in case you're happy
with an generator instead of a list. As you probably know, Python 3 only
has xrange (and it has been renamed to range).

--
Martin Geisler

Mercurial links: http://mercurial.ch/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 26 - 50 of 61 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »