www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - The amazing template which does nothing

reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Apr 27 2015
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/27/15 7:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
s/which/that/ Simple rule of thumb: if there's no comma before "which", consider replacing with "that". -- Andrei
Apr 27 2015
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 28 April 2015 at 06:10:28 UTC, Andrei Alexandrescu 
wrote:
 On 4/27/15 7:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
s/which/that/ Simple rule of thumb: if there's no comma before "which", consider replacing with "that". -- Andrei
Fixed, thanks.
Apr 27 2015
prev sibling next sibling parent reply "Chris" <wendlec tcd.ie> writes:
On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev 
wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Thanks for this little piece of information! Great stuff. You wrote "When building an UFCS chain (in the style of component programming), you will often run into situations where a certain operation is not UFCS-able. There are multiple obvious ways to prepend the string, but neither are very satisfactory" And this has happened to me many times. The solution "Break the UFCS chain and use a local temporary variable" makes me angry, because by having to do so all the beauty of chaining is lost.
Apr 28 2015
parent reply "Andrea Fontana" <nospam example.com> writes:
On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
 And this has happened to me many times. The solution "Break the 
 UFCS chain and use a local temporary variable" makes me angry, 
 because by having to do so all the beauty of chaining is lost.
A very slow (i guess) workaround could be: "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln; vs the new one: "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
Apr 28 2015
next sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote:
 On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
 And this has happened to me many times. The solution "Break 
 the UFCS chain and use a local temporary variable" makes me 
 angry, because by having to do so all the beauty of chaining 
 is lost.
A very slow (i guess) workaround could be: "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln; vs the new one: "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
Shouldn't be slow, your just giving the optimiser some work to do*, but you're always better off with the second one. *Assuming a good optimiser. dmd won't work this out.
Apr 28 2015
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 28 April 2015 at 10:18:12 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote:
 On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
 And this has happened to me many times. The solution "Break 
 the UFCS chain and use a local temporary variable" makes me 
 angry, because by having to do so all the beauty of chaining 
 is lost.
A very slow (i guess) workaround could be: "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln; vs the new one: "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
Shouldn't be slow, your just giving the optimiser some work to do*, but you're always better off with the second one. *Assuming a good optimiser. dmd won't work this out.
s/your/you're
Apr 28 2015
parent reply "Andrea Fontana" <nospam example.com> writes:
On Tuesday, 28 April 2015 at 10:18:49 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 10:18:12 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana 
 wrote:
 On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
 And this has happened to me many times. The solution "Break 
 the UFCS chain and use a local temporary variable" makes me 
 angry, because by having to do so all the beauty of chaining 
 is lost.
A very slow (i guess) workaround could be: "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln; vs the new one: "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
Shouldn't be slow, your just giving the optimiser some work to do*, but you're always better off with the second one. *Assuming a good optimiser. dmd won't work this out.
s/your/you're
Trying on d.godbolt.com it seems a lot of extra-code is generated for the first version. Anyway I think I'm going to rename it "apply". :) "test".toUpper.apply!(a => "This is a " ~ a).writeln; It sounds better.
Apr 28 2015
next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 On Tuesday, 28 April 2015 at 10:18:49 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 10:18:12 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana 
 wrote:
 On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
 And this has happened to me many times. The solution "Break 
 the UFCS chain and use a local temporary variable" makes me 
 angry, because by having to do so all the beauty of 
 chaining is lost.
A very slow (i guess) workaround could be: "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln; vs the new one: "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
Shouldn't be slow, your just giving the optimiser some work to do*, but you're always better off with the second one. *Assuming a good optimiser. dmd won't work this out.
s/your/you're
Trying on d.godbolt.com it seems a lot of extra-code is generated for the first version. Anyway I think I'm going to rename it "apply". :) "test".toUpper.apply!(a => "This is a " ~ a).writeln; It sounds better.
The d.godbolt.org compilers seem a little out of date. I have found problems with their codegen/optimisation that doesn't happen in more recent versions. ldc 0.15.2 based on llvm 3.5.1 reduces both chains to identical asm.
Apr 28 2015
prev sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is 
 generated for the first version.
d.godbolt.com is dead, use asm.dlang.org
Apr 28 2015
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev 
wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is 
 generated for the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Apr 29 2015
next sibling parent reply Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 29 Apr 2015 09:05, "John Colvin via Digitalmars-d" <
digitalmars-d puremagic.com> wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is generated for
the first version.
 d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the
latest GDC shortly. asm.dlang.org only has DMD. Well it's using frontend 2.055, which I guess would put it at gdc-4.6 in Debian repos.
Apr 29 2015
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Wednesday, 29 April 2015 at 07:49:34 UTC, Iain Buclaw wrote:
 On 29 Apr 2015 09:05, "John Colvin via Digitalmars-d" <
 digitalmars-d puremagic.com> wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev 
 wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana 
 wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is 
 generated for
the first version.
 d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the
latest GDC shortly. asm.dlang.org only has DMD. Well it's using frontend 2.055, which I guess would put it at gdc-4.6 in Debian repos.
Did you check the dropdown menu? There's 4.9 in there. Hopefully the latest release from gdcproject.org will be added in the next couple of days
Apr 29 2015
parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 29 April 2015 at 12:16, John Colvin via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Wednesday, 29 April 2015 at 07:49:34 UTC, Iain Buclaw wrote:
 On 29 Apr 2015 09:05, "John Colvin via Digitalmars-d" <
 digitalmars-d puremagic.com> wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is generated for
the first version.
 d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the
latest GDC shortly. asm.dlang.org only has DMD. Well it's using frontend 2.055, which I guess would put it at gdc-4.6 in Debian repos.
Did you check the dropdown menu? There's 4.9 in there. Hopefully the latest release from gdcproject.org will be added in the next couple of days
Ah! I was on my phone and didn't notice. :-O
Apr 29 2015
prev sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev 
 wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana 
 wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is 
 generated for the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Ah, my bad! I know Iain was involved so I thought it had GDC as well :)
Apr 29 2015
next sibling parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 29 April 2015 at 14:07, Vladimir Panteleev via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is generated for
 the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Ah, my bad! I know Iain was involved so I thought it had GDC as well :)
DMD and GDC don't generate compatible outputs, so it's not that straightforward to have both together. ;-) d.godbolt.org is better than asm.dlang.org because GDC emits assembly, you have more information to play around with (and syntax highlighting works thanks to .file and .loc assembler directives). asm.dlang.org is a basterdised version that removes all features because DMD emits object code, and there is no useful information you can pull from objdump. It is nice that you can test the latest daily on asm.dlang.org though... Iain.
Apr 29 2015
prev sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev 
wrote:
 On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev 
 wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana 
 wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is 
 generated for the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Ah, my bad! I know Iain was involved so I thought it had GDC as well :)
d.godbolt.org now has the latest release as default.
Apr 29 2015
parent reply Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 29 April 2015 at 14:50, John Colvin via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev wrote:
 On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is generated for
 the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Ah, my bad! I know Iain was involved so I thought it had GDC as well :)
d.godbolt.org now has the latest release as default.
I take it you've been speaking to the site maintainer? :o) Looks like he downloaded the binary off gdcproject.org?
Apr 29 2015
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Wednesday, 29 April 2015 at 14:18:49 UTC, Iain Buclaw wrote:
 On 29 April 2015 at 14:50, John Colvin via Digitalmars-d
 <digitalmars-d puremagic.com> wrote:
 On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir 
 Panteleev wrote:
 On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin 
 wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir 
 Panteleev wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana 
 wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is 
 generated for
 the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Ah, my bad! I know Iain was involved so I thought it had GDC as well :)
d.godbolt.org now has the latest release as default.
I take it you've been speaking to the site maintainer? :o) Looks like he downloaded the binary off gdcproject.org?
Yes and yes.
Apr 30 2015
parent Iain Buclaw via Digitalmars-d <digitalmars-d puremagic.com> writes:
On 30 April 2015 at 15:01, John Colvin via Digitalmars-d
<digitalmars-d puremagic.com> wrote:
 On Wednesday, 29 April 2015 at 14:18:49 UTC, Iain Buclaw wrote:
 On 29 April 2015 at 14:50, John Colvin via Digitalmars-d
 <digitalmars-d puremagic.com> wrote:
 On Wednesday, 29 April 2015 at 12:07:58 UTC, Vladimir Panteleev wrote:
 On Wednesday, 29 April 2015 at 07:00:15 UTC, John Colvin wrote:
 On Tuesday, 28 April 2015 at 21:19:53 UTC, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 10:24:27 UTC, Andrea Fontana wrote:
 Trying on d.godbolt.com it seems a lot of extra-code is generated for
 the first version.
d.godbolt.com is dead, use asm.dlang.org
d.godbolt.org (note .org not .com) works fine and will be updated to the latest GDC shortly. asm.dlang.org only has DMD.
Ah, my bad! I know Iain was involved so I thought it had GDC as well :)
d.godbolt.org now has the latest release as default.
I take it you've been speaking to the site maintainer? :o) Looks like he downloaded the binary off gdcproject.org?
Yes and yes.
You could have waited a month for gdc-5 to come out of experimental... https://packages.debian.org/experimental/gdc-5
Apr 30 2015
prev sibling parent "Andrea Fontana" <nospam example.com> writes:
On Tuesday, 28 April 2015 at 10:07:43 UTC, Andrea Fontana wrote:
 On Tuesday, 28 April 2015 at 09:23:53 UTC, Chris wrote:
 And this has happened to me many times. The solution "Break 
 the UFCS chain and use a local temporary variable" makes me 
 angry, because by having to do so all the beauty of chaining 
 is lost.
A very slow (i guess) workaround could be: "test".toUpper.only.map!(a => "This is a " ~ a).front.writeln; vs the new one: "test".toUpper.Identity!(a => "This is a " ~ a).writeln;
Using std.functional: "test".toUpper.unaryFun!(a => "This is a " ~ a).writeln;
Apr 28 2015
prev sibling next sibling parent "Dicebot" <public dicebot.lv> writes:
On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev 
wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Very nice. There is also a similar package protected template in std.typetuple, `Alias`. I used it a lot but last applicability case with UFCS chain didn't come to my mind. It looks very elegant. I had plans to introduce it as a public helper in std.meta under the name `Symbol`, would that make sense?
Apr 28 2015
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 4/27/15 7:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Went to post on reddit, was there already: http://www.reddit.com/r/programming/comments/345zw3/the_amazing_template_that_does_nothing/ I've also posted on these other sites: https://news.ycombinator.com/newest https://twitter.com/D_Programming/status/593135475537223680 https://www.facebook.com/dlang.org/posts/1059305784083102 Andrei
Apr 28 2015
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 28 April 2015 at 19:32:40 UTC, Andrei Alexandrescu 
wrote:
 On 4/27/15 7:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Went to post on reddit, was there already: http://www.reddit.com/r/programming/comments/345zw3/the_amazing_template_that_does_nothing/ I've also posted on these other sites:
Thank you, though the article is kinda targeted at experienced D developers. As the redditors have been quick to point out, most of these are basically workarounds for grammar quirks.
Apr 28 2015
prev sibling next sibling parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 4/27/15 10:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Very cool. Just a grammar nit, "an UFCS" should be "a UFCS". -Steve
Apr 28 2015
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 28 April 2015 at 21:42:04 UTC, Steven Schveighoffer 
wrote:
 On 4/27/15 10:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Very cool. Just a grammar nit, "an UFCS" should be "a UFCS".
Fixed, thanks. (I always found this rule counter-intuitive... "u" is a vowel dangit!)
Apr 28 2015
parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 4/28/15 6:00 PM, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 21:42:04 UTC, Steven Schveighoffer wrote:
 On 4/27/15 10:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Very cool. Just a grammar nit, "an UFCS" should be "a UFCS".
Fixed, thanks. (I always found this rule counter-intuitive... "u" is a vowel dangit!)
And in most cases, 'an' is correct. It's only when it makes a "you" sound (and if you spell out your acronyms, 'U' does), when you want to use 'a' :) an upsetting rule ('uh') an uber-cool language ('oo') a unique grammar problem ('you') -Steve
Apr 28 2015
parent reply "Chris" <wendlec tcd.ie> writes:
On Tuesday, 28 April 2015 at 22:29:40 UTC, Steven Schveighoffer 
wrote:
 On 4/28/15 6:00 PM, Vladimir Panteleev wrote:
 On Tuesday, 28 April 2015 at 21:42:04 UTC, Steven 
 Schveighoffer wrote:
 On 4/27/15 10:36 PM, Vladimir Panteleev wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Very cool. Just a grammar nit, "an UFCS" should be "a UFCS".
Fixed, thanks. (I always found this rule counter-intuitive... "u" is a vowel dangit!)
And in most cases, 'an' is correct. It's only when it makes a "you" sound (and if you spell out your acronyms, 'U' does), when you want to use 'a' :) an upsetting rule ('uh') an uber-cool language ('oo') a unique grammar problem ('you') -Steve
Yeah, because the sound in `you` or the letter <u> is not a full vowel but a semi-vowel /j/ (cf. German `ja`), also: a "voiced palatal approximant": https://en.wikipedia.org/wiki/Palatal_approximant Whenever a phonetic /u(:)/ becomes a /ju(:)/ (for whatever reason), rules for vowels no longer apply, simply because it is (phonetically speaking) no longer vowel, e.g. an + V => a + /j/. Cf a utilitarian point of view (*an utilitarian) /juː/ The spelling rule upsets you, because there is a mismatch between what you see on the page and how you pronounce it (vowel vs. consonant/semi-vowel). It also works the other way around: - an STL expert - a PhD student <s> describes a consonant but is pronounced with a vowel here /es/. Thus, you have to write `an`. Just follow your natural way of speaking and you'll be fine. Read it out to yourself. And let's be honest, it sounds really crap when you read "an UFCS", bahhh!
Apr 29 2015
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Wednesday, 29 April 2015 at 09:44:27 UTC, Chris wrote:
 Just follow your natural way of speaking and you'll be fine. 
 Read it out to yourself. And let's be honest, it sounds really 
 crap when you read "an UFCS", bahhh!
Yes, well, the problem is that "an U" sounds completely fine in my head! The way you pronounce the U letter in the English alphabet is the same (not sure if identical) as the Russian letter Ю, which is considered a vowel in Russian.
Apr 29 2015
parent reply "Chris" <wendlec tcd.ie> writes:
On Wednesday, 29 April 2015 at 09:57:01 UTC, Vladimir Panteleev 
wrote:
 On Wednesday, 29 April 2015 at 09:44:27 UTC, Chris wrote:
 Just follow your natural way of speaking and you'll be fine. 
 Read it out to yourself. And let's be honest, it sounds really 
 crap when you read "an UFCS", bahhh!
Yes, well, the problem is that "an U" sounds completely fine in my head! The way you pronounce the U letter in the English alphabet is the same (not sure if identical) as the Russian letter Ю, which is considered a vowel in Russian.
In that case you'll just have to learn the rule: if it's a single letter, it has to be `an`. Sorry, I didn't realize that /j/ is treated as a vowel in Russian. I was thinking of languages I'm familiar with, and there /j/ is always treated as a consonant. Is the Russian sound a fricative or a pure vowel without any friction (= obstruction)?
Apr 29 2015
parent reply "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
On Wednesday, 29 April 2015 at 10:09:39 UTC, Chris wrote:
 On Wednesday, 29 April 2015 at 09:57:01 UTC, Vladimir Panteleev 
 wrote:
 On Wednesday, 29 April 2015 at 09:44:27 UTC, Chris wrote:
 Just follow your natural way of speaking and you'll be fine. 
 Read it out to yourself. And let's be honest, it sounds 
 really crap when you read "an UFCS", bahhh!
Yes, well, the problem is that "an U" sounds completely fine in my head! The way you pronounce the U letter in the English alphabet is the same (not sure if identical) as the Russian letter Ю, which is considered a vowel in Russian.
In that case you'll just have to learn the rule: if it's a single letter, it has to be `an`. Sorry, I didn't realize that /j/ is treated as a vowel in Russian. I was thinking of languages I'm familiar with, and there /j/ is always treated as a consonant. Is the Russian sound a fricative or a pure vowel without any friction (= obstruction)?
Can't answer that question, but <Ю> is actually [ju] in isolation, that is, a glide + a vowel. When preceded by a consonant, that glide is not pronounced, instead the consonant gets palatalized. Thus it would be better to say that /ju/ is treated as a vowel, not /j/.
Apr 29 2015
parent "Chris" <wendlec tcd.ie> writes:
On Wednesday, 29 April 2015 at 10:15:52 UTC, Marc Schütz wrote:
 On Wednesday, 29 April 2015 at 10:09:39 UTC, Chris wrote:
 On Wednesday, 29 April 2015 at 09:57:01 UTC, Vladimir 
 Panteleev wrote:
 On Wednesday, 29 April 2015 at 09:44:27 UTC, Chris wrote:
 Just follow your natural way of speaking and you'll be fine. 
 Read it out to yourself. And let's be honest, it sounds 
 really crap when you read "an UFCS", bahhh!
Yes, well, the problem is that "an U" sounds completely fine in my head! The way you pronounce the U letter in the English alphabet is the same (not sure if identical) as the Russian letter Ю, which is considered a vowel in Russian.
In that case you'll just have to learn the rule: if it's a single letter, it has to be `an`. Sorry, I didn't realize that /j/ is treated as a vowel in Russian. I was thinking of languages I'm familiar with, and there /j/ is always treated as a consonant. Is the Russian sound a fricative or a pure vowel without any friction (= obstruction)?
Can't answer that question, but <Ю> is actually [ju] in isolation, that is, a glide + a vowel. When preceded by a consonant, that glide is not pronounced, instead the consonant gets palatalized. Thus it would be better to say that /ju/ is treated as a vowel, not /j/.
Hm, a glide is not necessarily a fricative. In English the /j/ sometimes comes close to /ç/, as in German `ich`. A glide would be more like /ɪu/, however, in this environment glides tend to have some sort of friction, it's almost unavoidable. Interesting, though, how the same sounds are perceived differently in different languages.
Apr 29 2015
prev sibling next sibling parent reply "Max Samukha" <maxsamukha gmail.com> writes:
On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev 
wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
A truly polymorphic identity function in D would be more involved: template id(a...) if (a.length == 1) { static if (__traits(compiles, { alias id = a[0]; } )) alias id = a[0]; else enum id = a[0]; } static assert(is(id!int == int)); static assert(id!1 == 1); Also, an 'isEqual' template would be needed to unify 'isSame', 'is' and '=='.
Apr 28 2015
parent "Dicebot" <public dicebot.lv> writes:
On Tuesday, 28 April 2015 at 22:24:53 UTC, Max Samukha wrote:
 On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev 
 wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
A truly polymorphic identity function in D would be more involved: template id(a...) if (a.length == 1) { static if (__traits(compiles, { alias id = a[0]; } )) alias id = a[0]; else enum id = a[0]; } static assert(is(id!int == int)); static assert(id!1 == 1); Also, an 'isEqual' template would be needed to unify 'isSame', 'is' and '=='.
Actually I do find more specialized names/implementations useful in this case. For example, just the fact that you use `unaryFun!(a => a)` instead of `Identity!(a => a)` makes code more readable and intention clear even if effect is the same.
Apr 28 2015
prev sibling parent reply "Nikolay" <sibnick gmail.com> writes:
On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev 
wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Thanks for good article little mistake: return from void function: /// Search a website for something, and parse the /// first search result's webpage. void getItemInfo(string itemName) { // Let's go! First, construct the URL. return ("http://www.example.com/search?q=" ~ encodeComponent(itemName)) .......
Apr 28 2015
parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Wednesday, 29 April 2015 at 06:56:37 UTC, Nikolay wrote:
 On Tuesday, 28 April 2015 at 02:36:38 UTC, Vladimir Panteleev 
 wrote:
 http://blog.thecybershadow.net/2015/04/28/the-amazing-template-which-does-nothing/
Thanks for good article little mistake: return from void function: /// Search a website for something, and parse the /// first search result's webpage. void getItemInfo(string itemName) { // Let's go! First, construct the URL. return ("http://www.example.com/search?q=" ~ encodeComponent(itemName)) .......
Fixed, thanks. Though, you technically still can use "return expression" in a void function, as long as expression's type is void :)
Apr 29 2015