Thread overview
Non-English characters in code - "character 0x2212 is not a valid token"
Jan 28, 2016
pineapple
Jan 28, 2016
pineapple
Jan 28, 2016
Andrea Fontana
Jan 28, 2016
sigod
Jan 28, 2016
Adam D. Ruppe
Feb 04, 2016
sigod
January 28, 2016
I experimented with using the character 'ħ' in a variable name, and wasn't terribly surprised when the compiler didn't like it. What did surprise me is that I still got a compile error even when the character was in a comment. Is there any way to make dmd not get fussy about unicode?
January 28, 2016
On Thursday, 28 January 2016 at 13:18:55 UTC, pineapple wrote:
> I experimented with using the character 'ħ' in a variable name, and wasn't terribly surprised when the compiler didn't like it. What did surprise me is that I still got a compile error even when the character was in a comment. Is there any way to make dmd not get fussy about unicode?

Oh, don't mind me. Turns out the problem was nothing to do with 'ħ', somehow a '-' that wasn't actually a '-' found its way into my code and was confusing my numeric literals. All is well here.
January 28, 2016
On Thursday, 28 January 2016 at 13:18:55 UTC, pineapple wrote:
> I experimented with using the character 'ħ' in a variable name, and wasn't terribly surprised when the compiler didn't like it. What did surprise me is that I still got a compile error even when the character was in a comment. Is there any way to make dmd not get fussy about unicode?

Hmmm it's strange: I think d should support unicode on both comment and vars name.

This code works for me ;)

float distance(T)(T from, T to)
      {
         import std.math;

         auto toRadians = (float dec) => dec/180.0f*PI;

         auto R = 6371;
         auto φ1 = toRadians(from.lat);
         auto φ2 = toRadians(to.lat);
         auto Δφ = toRadians(to.lat-from.lat);
         auto Δλ = toRadians(to.lng-from.lng);

         float a = sin(Δφ/2) * sin(Δφ/2) + cos(φ1) * cos(φ2) * sin(Δλ/2) * sin(Δλ/2);
         float c = 2 * atan2(sqrt(a), sqrt(1-a));

         return R * c;

      }
January 28, 2016
On Thursday, 28 January 2016 at 13:26:27 UTC, Andrea Fontana wrote:
> On Thursday, 28 January 2016 at 13:18:55 UTC, pineapple wrote:
>> I experimented with using the character 'ħ' in a variable name, and wasn't terribly surprised when the compiler didn't like it. What did surprise me is that I still got a compile error even when the character was in a comment. Is there any way to make dmd not get fussy about unicode?
>
> Hmmm it's strange: I think d should support unicode on both comment and vars name.
>
> This code works for me ;)
>
> float distance(T)(T from, T to)
>       {
>          import std.math;
>
>          auto toRadians = (float dec) => dec/180.0f*PI;
>
>          auto R = 6371;
>          auto φ1 = toRadians(from.lat);
>          auto φ2 = toRadians(to.lat);
>          auto Δφ = toRadians(to.lat-from.lat);
>          auto Δλ = toRadians(to.lng-from.lng);
>
>          float a = sin(Δφ/2) * sin(Δφ/2) + cos(φ1) * cos(φ2) * sin(Δλ/2) * sin(Δλ/2);
>          float c = 2 * atan2(sqrt(a), sqrt(1-a));
>
>          return R * c;
>
>       }

What compiler version do you use?

I tried to compile your code on dpaste (2.070.0) and got this:

	/d213/f100.d(8): Error: character '\' is not a valid token
	/d213/f100.d(9): Error: character '\' is not a valid token
	/d213/f100.d(10): Error: character '\' is not a valid token
	/d213/f100.d(10): Error: character '\' is not a valid token
	/d213/f100.d(11): Error: character '\' is not a valid token
	/d213/f100.d(11): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: found 'u03c6' when expecting ','
	/d213/f100.d(13): Error: expression expected, not '/'
	/d213/f100.d(13): Error: found '2' when expecting ','
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: found 'u03c6' when expecting ','
	/d213/f100.d(13): Error: expression expected, not '/'
	/d213/f100.d(13): Error: found '2' when expecting ','
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: character '\' is not a valid token
	/d213/f100.d(13): Error: character '\' is not a valid token
January 28, 2016
On Thursday, 28 January 2016 at 14:39:46 UTC, sigod wrote:
> I tried to compile your code on dpaste (2.070.0) and got this:

dpaste has an input mangling bug with some characters as a result of the form submission over the web.
February 04, 2016
On Thursday, 28 January 2016 at 14:45:36 UTC, Adam D. Ruppe wrote:
> On Thursday, 28 January 2016 at 14:39:46 UTC, sigod wrote:
>> I tried to compile your code on dpaste (2.070.0) and got this:
>
> dpaste has an input mangling bug with some characters as a result of the form submission over the web.

Oh, I see.

Is there any place where one can report bugs on dpaste?