digitalmars.D.learn - Non-English characters in code - "character 0x2212 is not a valid
- pineapple (5/5) Jan 28 2016 I experimented with using the character 'ħ' in a variable name,
- pineapple (4/9) Jan 28 2016 Oh, don't mind me. Turns out the problem was nothing to do with
- Andrea Fontana (18/23) Jan 28 2016 Hmmm it's strange: I think d should support unicode on both
- sigod (24/47) Jan 28 2016 What compiler version do you use?
- Adam D. Ruppe (3/4) Jan 28 2016 dpaste has an input mangling bug with some characters as a result
- sigod (3/7) Feb 04 2016 Oh, I see.
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?
Jan 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.
Jan 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; }
Jan 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: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 tokenI 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; }
Jan 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.
Jan 28 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:Oh, I see. Is there any place where one can report bugs on dpaste?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.
Feb 04 2016