www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Pure

reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
Is pure meant to be a compiler hint so that it is up to the 
programmer to enforce it? It is sometimes useful to maintain 
hidden state for lazy evaluation, that does not affect purity 
optimizations:

e.g.

a = foo(1) // evaluates, caches and returns value
b = foo(1) // returns cached value
c = foo (1) // returns cached value

is optimized to

a = b = c = foo(1) // evaluates, caches and returns value
Jan 08 2014
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Ola Fosheim Grøstad:

 Is pure meant to be a compiler hint so that it is up to the 
 programmer to enforce it?
Nope, it's enforced by the compiler. (But its rules are not immediately obvious, there are three kinds of purity, strong, weak and constant purity, etc). There are several corners cases, etc. Bye, bearophole
Jan 08 2014
prev sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Wednesday, 8 January 2014 at 18:40:46 UTC, Ola Fosheim Grøstad 
wrote:
 Is pure meant to be a compiler hint so that it is up to the 
 programmer to enforce it? It is sometimes useful to maintain 
 hidden state for lazy evaluation, that does not affect purity 
 optimizations:

 e.g.

 a = foo(1) // evaluates, caches and returns value
 b = foo(1) // returns cached value
 c = foo (1) // returns cached value

 is optimized to

 a = b = c = foo(1) // evaluates, caches and returns value
pure is enforced by the compiler (bugs allowing...). However, D purity has more shades to it than the black and white concept that most are familiar with. I'll leave it to someone who knows better to explain it.
Jan 08 2014
parent reply "Paolo Invernizzi" <paolo.invernizzi gmail.com> writes:
On Wednesday, 8 January 2014 at 19:04:24 UTC, John Colvin wrote:
 On Wednesday, 8 January 2014 at 18:40:46 UTC, Ola Fosheim 
 Grøstad wrote:
 Is pure meant to be a compiler hint so that it is up to the 
 programmer to enforce it? It is sometimes useful to maintain 
 hidden state for lazy evaluation, that does not affect purity 
 optimizations:
pure is enforced by the compiler (bugs allowing...). However, D purity has more shades to it than the black and white concept that most are familiar with. I'll leave it to someone who knows better to explain it.
This one is a good introduction, or at least the best one I can remember: http://klickverbot.at/blog/2012/05/purity-in-d/ Very well written, a pleasure to read. /Paolo
Jan 08 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/08/2014 11:09 AM, Paolo Invernizzi wrote:

 This one is a good introduction, or at least the best one I can remember:

 http://klickverbot.at/blog/2012/05/purity-in-d/

 Very well written, a pleasure to read.
And very hard to translate! :) In case a Turkish reader is interested, here is the translation: http://ddili.org/makale/saflik.html Ali
Jan 08 2014
next sibling parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Wednesday, 8 January 2014 at 19:26:28 UTC, Ali Çehreli wrote:
 And very hard to translate! :) In case a Turkish reader is 
 interested, here is the translation:

   http://ddili.org/makale/saflik.html
So, "saflik" is "pure" in turkish, cool! I like the sound of it. 8-D
Jan 08 2014
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/08/2014 11:39 AM, "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang gmail.com>" wrote:> On Wednesday, 8 January 
2014 at 19:26:28 UTC, Ali Çehreli wrote:
 And very hard to translate! :) In case a Turkish reader is interested,
 here is the translation:

   http://ddili.org/makale/saflik.html
So, "saflik" is "pure" in turkish, cool! I like the sound of it. 8-D
It is never easy, is it? :) The reason it is "saflik" in the URL is because file names better be in ASCII due to different capabilities of different file systems. The word is actually "saflık". saf means pure and saflık means "purity". The vowel ı does not appear in English: It is close to the sound made just before the 'n' in "action" but not exactly the same. Ali
Jan 08 2014
parent "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Wednesday, 8 January 2014 at 21:37:24 UTC, Ali Çehreli wrote:
 On 01/08/2014 11:39 AM, "Ola Fosheim Grøstad"
 So, "saflik" is "pure" in turkish, cool! I like the sound of
it. 8-D It is never easy, is it? :) The reason it is "saflik" in the URL is because file names better be in ASCII due to different capabilities of different file systems. The word is actually "saflık". saf means pure and saflık means "purity". The vowel ı does not appear in English: It is close to the sound made just before the 'n' in "action" but not exactly the same.
I am trying very hard to put the "action" phoneme into "saflık", not sure if I got it irght, but I still like the sound of it! :-) And thanks to the list members that put some light on the diversity of "pure" in D, for me.
Jan 09 2014
prev sibling parent reply John Carter <john.carter taitradio.com> writes:
 Very well written, a pleasure to read.
 And very hard to translate! :)
Leaping off the immediate topic of computer language D into the realm of human languages English and Turkish... With the Sapir–Whorf hypothesis in the back of my mind... What makes it harder to translate? Is there a human language in which these concepts would be more easily discussed? I was always fascinated by early translations (1980 and before era) of Japanese machine manuals... It was tempting to find the mistranslations funny, until I realised... * You could never remember the words. Your memory is fundamentally governed by the language you speak. Thus when you try remember (and relate to a colleague) a subtly garbled chunk of that language, your brain autocorrects it and refuses to reproduce the mistakes! * The differences indicated curious and subtle differences in thought processes of the original authors and translators. Not better or worse processes. Different. Interesting. Subtle. * The categories of mistakes made by, say German German to English translators, were very different. So I have always been fascinated by Sapir-Whorf, but it seems to be very subtle and nuanced and unexpected in practical effect. On Thu, Jan 9, 2014 at 8:26 AM, Ali Çehreli <acehreli yahoo.com> wrote:
 On 01/08/2014 11:09 AM, Paolo Invernizzi wrote:

 This one is a good introduction, or at least the best one I can remember:

 http://klickverbot.at/blog/2012/05/purity-in-d/

 Very well written, a pleasure to read.
And very hard to translate! :) In case a Turkish reader is interested, here is the translation: http://ddili.org/makale/saflik.html Ali
-- John Carter Phone : (64)(3) 358 6639 Tait Electronics PO Box 1645 Christchurch New Zealand -- ------------------------------ This email, including any attachments, is only for the intended recipient. It is subject to copyright, is confidential and may be the subject of legal or other privilege, none of which is waived or lost by reason of this transmission. If you are not an intended recipient, you may not use, disseminate, distribute or reproduce such email, any attachments, or any part thereof. If you have received a message in error, please notify the sender immediately and erase all copies of the message and any attachments. Unfortunately, we cannot warrant that the email has not been altered or corrupted during transmission nor can we guarantee that any email or any attachments are free from computer viruses or other conditions which may damage or interfere with recipient data, hardware or software. The recipient relies upon its own procedures and assumes all risk of use and of opening any attachments. ------------------------------
Jan 08 2014
next sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/08/2014 12:20 PM, John Carter wrote:

 Very well written, a pleasure to read.
 And very hard to translate! :)
Leaping off the immediate topic of computer language D into the realm of human languages English and Turkish... With the Sapir–Whorf hypothesis in the back of my mind... What makes it harder to translate?
What made is harder to translate was myself because I found some of the sentences in the original article more complicated than my little mind could handle. :) I find languages fascinating myself. Agreeing with everything you said, merely the innateness of the whole thing and the way languages mutate on their own is sufficient fascination for me. Ali
Jan 08 2014
prev sibling parent "Meta" <jared771 gmail.com> writes:
On Wednesday, 8 January 2014 at 20:21:22 UTC, John Carter wrote:
 Very well written, a pleasure to read.
 And very hard to translate! :)
Leaping off the immediate topic of computer language D into the realm of human languages English and Turkish... With the Sapir–Whorf hypothesis in the back of my mind... What makes it harder to translate? Is there a human language in which these concepts would be more easily discussed? I was always fascinated by early translations (1980 and before era) of Japanese machine manuals... It was tempting to find the mistranslations funny, until I realised... * You could never remember the words. Your memory is fundamentally governed by the language you speak. Thus when you try remember (and relate to a colleague) a subtly garbled chunk of that language, your brain autocorrects it and refuses to reproduce the mistakes! * The differences indicated curious and subtle differences in thought processes of the original authors and translators. Not better or worse processes. Different. Interesting. Subtle. * The categories of mistakes made by, say German German to English translators, were very different. So I have always been fascinated by Sapir-Whorf, but it seems to be very subtle and nuanced and unexpected in practical effect. On Thu, Jan 9, 2014 at 8:26 AM, Ali Çehreli <acehreli yahoo.com> wrote:
 On 01/08/2014 11:09 AM, Paolo Invernizzi wrote:

 This one is a good introduction, or at least the best one I 
 can remember:

 http://klickverbot.at/blog/2012/05/purity-in-d/

 Very well written, a pleasure to read.
And very hard to translate! :) In case a Turkish reader is interested, here is the translation: http://ddili.org/makale/saflik.html Ali
On a small tangent, I believe the Sapir-Whorf thesis has been disproved. However, I definitely think there might be a similar effect of programming languages on programmers.
Jan 09 2014