December 14, 2006
On Thu, 14 Dec 2006 12:57:11 -0800, Bill Baxter <wbaxter@gmail.com> wrote:

>> And I need alias arguments as syntax sugar like:
>>   alias(alias i) exp=i*2;
>> same as:
>>   template exp(alias i){
>>     alias exp=i*2;
>>   }
>
> Hmm, yeh not sure about that.  Have to get everyone to swallow the expression alias idea first, which will be tough because they've all been brainwashed into thinking that #define is the 8th deadly sin.  :-P
>
> --bb


8th deadly sin?

No..no..no... I'm sure you meant 1st deadly sin! ;D

-JJR
December 15, 2006
Bill Baxter wrote:
> nazo wrote:
>> Expressions! Expressions!  (/ ~.)/
>>
>> I think that the exchange of parameters of alias is necessary from:
>>   alias (x*2) exp;
>> to:
>>   alias exp=x*2;
> 
> I'm all for that.  Changing the order I mean, not necessarily aliases for expressions.  Typedef too.  They're all just saying symbol=value (where 'value' is a type).  But probably it will never change.  Alias is too closely connected to typedef, and typedef is too closely connected to C/C++ for Walter to change its syntax.  End result: neither will change.
void unyu(){writefln("unyu");};
alias[] funcs=[unyu,unyu,unyu];
foreach(f;funcs)f();
>> And I need alias arguments as syntax sugar like:
>>   alias(alias i) exp=i*2;
>> same as:
>>   template exp(alias i){
>>     alias exp=i*2;
>>   }
> 
> Hmm, yeh not sure about that. 
I rewrite this idea:
current:
  template f(alias i){
    const int f=i*10;
  }
suggestion of syntax sugar:
  const int f(alias i)=i*10;
> Have to get everyone to swallow the expression alias idea first, which will be tough because they've all been brainwashed into thinking that #define is the 8th deadly sin.  :-P
the preprocessor is the 8th deadly sin! but alias and template are not bad-knowhow!
December 15, 2006
Bill Baxter wrote:
> nazo wrote:
>> Expressions! Expressions!  (/ ~.)/
>>
>> I think that the exchange of parameters of alias is necessary from:
>>   alias (x*2) exp;
>> to:
>>   alias exp=x*2;
> 
> I'm all for that.  Changing the order I mean, not necessarily aliases for expressions.  Typedef too.  They're all just saying symbol=value (where 'value' is a type).  But probably it will never change.  Alias is too closely connected to typedef, and typedef is too closely connected to C/C++ for Walter to change its syntax.  End result: neither will change.
> 
>> And I need alias arguments as syntax sugar like:
>>   alias(alias i) exp=i*2;
>> same as:
>>   template exp(alias i){
>>     alias exp=i*2;
>>   }
> 
> Hmm, yeh not sure about that.  Have to get everyone to swallow the expression alias idea first, which will be tough because they've all been brainwashed into thinking that #define is the 8th deadly sin.  :-P
> 
> --bb

Actually its the 9th deadly sin.  The 8th would be copy constructors.  That said, i'm actually intrigued by the idea of a expression aliases.  I can think of ways they might well be useful -- and I think changing the syntax to "'alias' ident '=' expr ';'" for this particular case wouldn't be too bad either.  (If nothing else it would make it perfeclty clear to a parser that this is an expression-alias rather than a symbol-alias.)

-- Chris Nicholson-Sauls
December 15, 2006
nazo wrote:
> suggestion of syntax sugar:
>   const int f(alias i)=i*10;

Makes me think of my hypothetical Boar language...

# // Boar example
# module #Math;
# function Float sqr  ($n) = $n * $n;
# function Float cube ($n) = #Math:sqr($n) * $n;

Therefore, naturally, I'm not against it.  :)

-- Chris Nicholson-Sauls
December 15, 2006
Here is my patch for variable template 'without' alias and typedef.

Test Code:
const int test(int x) = x*2;

void main(){
   static assert(test!(5)==10);
}

#sorry for my poor English.


December 15, 2006
Alexander Panek wrote:
> Xinok wrote:
> 
> Technically, you can change a constant value in C++, too, if you want. Just get the address and write a little inline assembler to mov x, y something else there. I can't imagine what'd hold me off from that.

Actually that would be very difficult to make work, with optimisation. You'd have to find and replace every position the const was used (including ones that have been combined with other constants and optimizations) and replace them.
December 16, 2006
janderson wrote:
> Alexander Panek wrote:
>> Xinok wrote:
>>
>> Technically, you can change a constant value in C++, too, if you want. Just get the address and write a little inline assembler to mov x, y something else there. I can't imagine what'd hold me off from that.
> 
> Actually that would be very difficult to make work, with optimisation. You'd have to find and replace every position the const was used (including ones that have been combined with other constants and optimizations) and replace them.

This depends on how you used const.

const uint x = 1; // this is your case, the variable is just set in and has no unique memory address

class X {
   const uint x;

   this ( ) {
      this.x = 0; // here, x has an address and const is meant to be a write-once variable, not a constant value as above.
   }
}


Alex
1 2 3
Next ›   Last »