January 23, 2003
Russell Lewis wrote:
> Ilya Minkov wrote:
> 
>> Ilya Minkov wrote:
>>
>>> Walter, please add a new operator!
>>>
>>
>> One more. D doesn't seem to have a "power of" operator. Would '**' be OK?
>>
>> BTW, OCaml defines a set of symbols, of which operator tokens can be constructed, to which belong /*-+<>| for example. What do you think, overloadable operators which consist of a free combination of a certain set of characters?
>>
>> '//' would make a good integer division, if it just wasn't already a comment!
>>
>> -i.
>>
> 
> A "power of" operator would be a very good idea, but we need to stay away from **, IMHO.  The expression:
> 
>     a ** b
> 
> would then have to be interpreted as "a to the power of b" even though people coming from C would say that b was a pointer being dereferenced...

I've always used ^ informally. ^ or ^^ would get my vote, but there doesn't seem to me to be all that much reason for it, unless the compiler can use intrinsics to speed it up a lot more than a library function.

Evan


January 23, 2003
"Evan McClanahan" <evan@dontSPAMaltarinteractive.com> escreveu na mensagem news:b0p2ab$2p7f$1@digitaldaemon.com...
> Russell Lewis wrote:
> > Ilya Minkov wrote:
> >
> >> Ilya Minkov wrote:
> >>
> >>> Walter, please add a new operator!
> >>>
> >>
> >> One more. D doesn't seem to have a "power of" operator. Would '**' be
OK?
> >>
> >> BTW, OCaml defines a set of symbols, of which operator tokens can be constructed, to which belong /*-+<>| for example. What do you think, overloadable operators which consist of a free combination of a certain set of characters?
> >>
> >> '//' would make a good integer division, if it just wasn't already a comment!
> >>
> >> -i.
> >>
> >
> > A "power of" operator would be a very good idea, but we need to stay away from **, IMHO.  The expression:
> >
> >     a ** b
> >
> > would then have to be interpreted as "a to the power of b" even though people coming from C would say that b was a pointer being
dereferenced...
>
> I've always used ^ informally. ^ or ^^ would get my vote, but there doesn't seem to me to be all that much reason for it, unless the compiler can use intrinsics to speed it up a lot more than a library function.
>
> Evan
>
Defining a "pow" operator would be good for writing templates. Also it would be a operator available for overloading. A library function can't be properly dispatched in templates without using type specialization tricks. But IMO the "pow" operator should be defined for floats, so we can write "2 ^ 2" and "16 ^ 0.5" without problems.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 10/1/2003


January 24, 2003
^ is also already spoken for, but ^^ would work.  Unless someone wants to introduce a logical XOR, which does in fact have a certain amount of support.

a ^^ b;   // a raised to the b'th power

Maybe back quote?

a ` b;

nah, looks wierd.  Anyone?

Sean

"Russell Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message news:3E30085D.7090002@deming-os.org...
> Ilya Minkov wrote:
> > Ilya Minkov wrote:
> >
> >> Walter, please add a new operator!
> >>
> >
> > One more. D doesn't seem to have a "power of" operator. Would '**' be
OK?
> >
> > BTW, OCaml defines a set of symbols, of which operator tokens can be constructed, to which belong /*-+<>| for example. What do you think, overloadable operators which consist of a free combination of a certain set of characters?
> >
> > '//' would make a good integer division, if it just wasn't already a comment!
> >
> > -i.
> >
>
> A "power of" operator would be a very good idea, but we need to stay away from **, IMHO.  The expression:
>
> a ** b
>
> would then have to be interpreted as "a to the power of b" even though people coming from C would say that b was a pointer being dereferenced...


January 24, 2003
When applied to constants it could be computed at compile time.  It should at very least be an intrinsic, if not an actual operator.

Sean

"Evan McClanahan" <evan@dontSPAMaltarinteractive.com> wrote in message news:b0p2ab$2p7f$1@digitaldaemon.com...

> > would then have to be interpreted as "a to the power of b" even though people coming from C would say that b was a pointer being
dereferenced...
>
> I've always used ^ informally. ^ or ^^ would get my vote, but there doesn't seem to me to be all that much reason for it, unless the compiler can use intrinsics to speed it up a lot more than a library function.
>
> Evan


January 24, 2003
^ is already XOR.  You could accidentally write 2^2 thinking it'll be 4, but it'll produce 0.

2^^2 is unambiguous.

We need to be able to overload this because complex and quaternion can be raised to powers;  they have exp and ln defined for them.  Ok, so we could just overload pow(quat,float) and pow(complex,float) instead.  But I wouldn't mind having another operator or seven.  ;)  Need a few more with higher precedence than multiply, but lower precedence than exponentiation, so we can overload an operator for dot and cross product (aka inner and outer product).

Sean

"Daniel Yokomiso" <daniel_yokomiso@yahoo.com.br> wrote in message news:b0purq$948$1@digitaldaemon.com...
> Defining a "pow" operator would be good for writing templates. Also it
would
> be a operator available for overloading. A library function can't be properly dispatched in templates without using type specialization tricks. But IMO the "pow" operator should be defined for floats, so we can write
"2
> ^ 2" and "16 ^ 0.5" without problems.


January 24, 2003
Sean L. Palmer wrote:
> ^ is also already spoken for, but ^^ would work.  Unless someone wants to
> introduce a logical XOR, which does in fact have a certain amount of
> support.
> 
> a ^^ b;   // a raised to the b'th power
> 
> Maybe back quote?
> 
> a ` b;
> 
> nah, looks wierd.  Anyone?

right!  forgot about xor...  Someone mentioned ^^ could be logical xor, but I think that exponentiantion would be used more often for most people than logical xor (which can be worked around with the standard notation in any case).  I would support ^^ more readily than any of the other notations that I can think of.

Evan

January 24, 2003
Sean L. Palmer wrote:
> a ` b;
> 
> nah, looks wierd.  Anyone?

I'm not sure all keyboard layouts allow you to type it. Is it a part of original "one step for a man, a leap for a mankind" ASCII?

Let's take a look a the keyboard. These seem to be untaken, if i remember right:

\§$#@:

',' and '?' are taken, but i question them.

-i.

January 24, 2003
>"Ilya Minkov" <midiclub@8ung.at> wrote in message
news:b0rkpc$1493$1@digitaldaemon.com...
>>Sean L. Palmer wrote:
>> a ` b;
>>
>> nah, looks wierd.  Anyone?

>I'm not sure all keyboard layouts allow you to type it. Is it a part of original "one step for a man, a leap for a mankind" ASCII?

Yes, it is.  Right before lowercase 'a'.  It may not be on all keyboards though.

>Let's take a look a the keyboard. These seem to be untaken, if i remember right:

> \§$#@:

That's a foreign keyboard.  In the US we don't have the '§' key.

> ',' and '?' are taken, but i question them.

Comma seems necessary.  The comma operator seems fraught with potential for obscurity.  I never found a real legitimate use for it except during operator overloading, you can use it to construct lists.  Which is opposite of its natural use in the C language.  I'd rather ',' always form lists of things, the way it does in a parameter list.

?:  is useful.  So useful in fact that one starts to wonder if we really need that pesky longwinded 'if' keyword at all.  ;)

Sean


January 24, 2003
Sean L. Palmer wrote:
> That's a foreign keyboard.  In the US we don't have the '§' key.

Urrr ignorrand ammerrrikanzzzz! :>
There are thousands of ways to identify me as not being american. My broken language, the e-mail adress, and so on. I have never been identified as not being an american by a keyboard though. One can also identify me as being non-german and non-austrian and and non-finnish non-noone-knows what. Although i doubt the last. But i'm pretty much sure i'm european since else i'd probably love C and hate Pascal.

It's a german keyboard. All 3 of mine have mutated to german lately. A look at the US keyboard has approved that it's not there. Well, who wants no law, needs no paragraph sign. :>

>>',' and '?' are taken, but i question them.
> 
> Comma seems necessary.  The comma operator seems fraught with potential for
> obscurity.  I never found a real legitimate use for it except during
> operator overloading, you can use it to construct lists.  Which is opposite
> of its natural use in the C language.  I'd rather ',' always form lists of
> things, the way it does in a parameter list.

Right, parameter lists. I couldn't understand before, why the function parameters are separated with ',', and struct members with ';'? Why are these enclosed () and these in {}?

Why do the uses of "()" vs.  "{}" and ',' vs. ';' have to be so subtly different? Here this, there that. Cook the soup after the most stupid recipy.

But what is the (expession1, expression2, expression3) comma operator for? I think it primarily has a value in conjunction with a preprocessor, which is now gone. For reason.

The result of a comma extression is assigned to another expression, or used in expressions. Why can't you write:

int param1 = { expression1; espression2; expression3}

This would make expressions-in-expression more legible, also allowing some parenthesis to alternate:

(1+{({x+1}*2)+1}*3)

And why can't:

struct SomeStruct (
	Mem1: int,
	Mem2: float
)

??? puzzle!

I still catch myself at finding out that "for(,,){}" is not exactly correct.


> ?:  is useful.  So useful in fact that one starts to wonder if we really
> need that pesky longwinded 'if' keyword at all.  ;)

Right. But Pascal feels OK without it. It contacts code in rare cases, doesn't make it more readable though. And it uses up that ':' too! Grr.

January 27, 2003
Sean L. Palmer wrote:
> Maybe back quote?
> 
> a ` b;
> 
> nah, looks wierd.  Anyone?

I now start to think that a tick "`" should be on every keyboard. Some languages, notably Lisp and Tick C make use of it. But maybe it should be kept for the same purpose as in these languages: dynamic code generation.

-i.

1 2
Next ›   Last »