Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 08, 2014 Pure | ||||
---|---|---|---|---|
| ||||
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 |
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | 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
|
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | 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.
|
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | 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 |
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paolo Invernizzi | 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 |
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | 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
|
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | > > 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. ------------------------------ |
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ola Fosheim Grøstad | 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 |
January 08, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Carter | 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 |
January 09, 2014 Re: Pure | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Carter | 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.
|
Copyright © 1999-2021 by the D Language Foundation