digitalmars.D - Pure functions in D
- Walter Bright <newshound1 digitalmars.com> Sep 22 2008
- Knud Soerensen <4tuu4k002 sneakemail.com> Sep 22 2008
- Walter Bright <newshound1 digitalmars.com> Sep 22 2008
- Jason House <jason.james.house gmail.com> Sep 22 2008
- bearophile <bearophileHUGS lycos.com> Sep 22 2008
- Brian Palmer <d brian.codekitchen.net> Sep 22 2008
- Jacob Carlborg <doobnet gmail.com> Sep 22 2008
- bearophile <bearophileHUGS lycos.com> Sep 22 2008
- Sergey Gromov <snake.scaly gmail.com> Sep 22 2008
- Brian Palmer <d brian.codekitchen.net> Sep 22 2008
- bearophile <bearophileHUGS lycos.com> Sep 22 2008
- renoX <renosky free.fr> Sep 26 2008
- "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> Sep 24 2008
- bearophile <bearophileHUGS lycos.com> Sep 24 2008
- "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> Sep 24 2008
- "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> Sep 24 2008
- renoX <renosky free.fr> Sep 26 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 22 2008
- Bruno Medeiros <brunodomedeiros+spam com.gmail> Sep 23 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 23 2008
- Bruno Medeiros <brunodomedeiros+spam com.gmail> Sep 24 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 24 2008
- Walter Bright <newshound1 digitalmars.com> Sep 22 2008
- downs <default_357-line yahoo.de> Sep 23 2008
- Leandro Lucarella <llucax gmail.com> Sep 24 2008
- Walter Bright <newshound1 digitalmars.com> Sep 26 2008
- "Denis Koroskin" <2korden gmail.com> Sep 22 2008
- "Denis Koroskin" <2korden gmail.com> Sep 22 2008
- "Denis Koroskin" <2korden gmail.com> Sep 24 2008
- "Bruce Adams" <tortoise_74 yeah.who.co.uk> Sep 25 2008
- bearophile <bearophileHUGS lycos.com> Sep 22 2008
- "Adam D. Ruppe" <destructionator gmail.com> Sep 22 2008
- Sean Kelly <sean invisibleduck.org> Sep 22 2008
- Christopher Wright <dhasenan gmail.com> Sep 22 2008
- Sean Kelly <sean invisibleduck.org> Sep 22 2008
- J Duncan <jtd514_ ameritech.net> Sep 22 2008
- "Saaa" <empty needmail.com> Sep 22 2008
- bearophile <bearophileHUGS lycos.com> Sep 22 2008
- "Saaa" <empty needmail.com> Sep 23 2008
- BCS <ao pathlink.com> Sep 22 2008
- Victor Tyurin <eaglux gmail.com> Sep 23 2008
- bearophile <bearophileHUGS lycos.com> Sep 23 2008
- Victor Tyurin <eaglux gmail.com> Sep 24 2008
- Victor Tyurin <eaglux gmail.com> Sep 24 2008
- BCS <ao pathlink.com> Sep 23 2008
- Yigal Chripun <yigal100 gmail.com> Sep 23 2008
- Ary Borenszweig <ary esperanto.org.ar> Sep 23 2008
- Yigal Chripun <yigal100 gmail.com> Sep 23 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 23 2008
- Yigal Chripun <yigal100 gmail.com> Sep 23 2008
- BCS <ao pathlink.com> Sep 23 2008
- Yigal Chripun <yigal100 gmail.com> Sep 24 2008
- BCS <ao pathlink.com> Sep 24 2008
- Alix Pexton <alixD.TpextonNO SPAMgmailD.Tcom> Sep 24 2008
- BCS <ao pathlink.com> Sep 24 2008
- Alix Pexton <alixD.TpextonNO SPAMgmailD.Tcom> Sep 24 2008
- Christopher Wright <dhasenan gmail.com> Sep 24 2008
- BCS <ao pathlink.com> Sep 23 2008
- Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> Sep 23 2008
- BCS <ao pathlink.com> Sep 23 2008
- Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> Sep 23 2008
- Ary Borenszweig <ary esperanto.org.ar> Sep 23 2008
- Christopher Wright <dhasenan gmail.com> Sep 23 2008
- Bruno Medeiros <brunodomedeiros+spam com.gmail> Sep 23 2008
- "Jarrett Billingsley" <jarrett.billingsley gmail.com> Sep 23 2008
- BCS <ao pathlink.com> Sep 23 2008
- BCS <ao pathlink.com> Sep 23 2008
- Benji Smith <dlanguage benjismith.net> Sep 27 2008
- "Jarrett Billingsley" <jarrett.billingsley gmail.com> Sep 23 2008
- "Jarrett Billingsley" <jarrett.billingsley gmail.com> Sep 23 2008
- "Bill Baxter" <wbaxter gmail.com> Sep 23 2008
- "Simen Kjaeraas" <simen.kjaras gmail.com> Sep 24 2008
- John H. Guillory <johng communicomm.com> Sep 24 2008
- Victor Tyurin <eaglux gmail.com> Sep 25 2008
- "Bruce Adams" <tortoise_74 yeah.who.co.uk> Sep 25 2008
- Bruno Medeiros <brunodomedeiros+spam com.gmail> Sep 23 2008
- Christopher Wright <dhasenan gmail.com> Sep 23 2008
- bearophile <bearophileHUGS lycos.com> Sep 23 2008
- "Steven Schveighoffer" <schveiguy yahoo.com> Sep 23 2008
- "Bill Baxter" <wbaxter gmail.com> Sep 23 2008
- Walter Bright <newshound1 digitalmars.com> Sep 26 2008
- Jason House <jason.james.house gmail.com> Sep 27 2008
- Leandro Lucarella <llucax gmail.com> Sep 27 2008
- Jason House <jason.james.house gmail.com> Sep 27 2008
- BCS <ao pathlink.com> Sep 28 2008
- bearophile <bearophileHUGS lycos.com> Sep 29 2008
- bearophile <bearophileHUGS lycos.com> Sep 29 2008
- renoX <renosky free.fr> Oct 02 2008
- bearophile <bearophileHUGS lycos.com> Oct 02 2008
- bearophile <bearophileHUGS lycos.com> Oct 02 2008
- Fawzi Mohamed <fmohamed mac.com> Oct 03 2008
- renoX <renosky free.fr> Oct 08 2008
- bearophile <bearophileHUGS lycos.com> Oct 08 2008
- renoX <renosky free.fr> Oct 09 2008
- bearophile <bearophileHUGS lycos.com> Oct 09 2008
- renoX <renosky free.fr> Oct 10 2008
- Ary Borenszweig <ary esperanto.org.ar> Sep 29 2008
- Sergey Gromov <snake.scaly gmail.com> Sep 29 2008
- Sean Kelly <sean invisibleduck.org> Sep 29 2008
- bearophile <bearophileHUGS lycos.com> Sep 29 2008
- Sean Kelly <sean invisibleduck.org> Sep 29 2008
- BCS <ao pathlink.com> Sep 29 2008
- bearophile <bearophileHUGS lycos.com> Sep 29 2008
- BCS <ao pathlink.com> Sep 29 2008
- Michel Fortin <michel.fortin michelf.com> Sep 27 2008
- dsimcha <dsimcha yahoo.com> Sep 27 2008
- Sergey Gromov <snake.scaly gmail.com> Sep 27 2008
- bearophile <bearophileHUGS lycos.com> Sep 27 2008
- Russell Lewis <webmaster villagersonline.com> Sep 29 2008
- Bruno Medeiros <brunodomedeiros+spam com.gmail> Oct 03 2008
- "Bill Baxter" <wbaxter gmail.com> Sep 27 2008
Walter Bright wrote:http://www.reddit.com/r/programming/comments/72r6q/walter_bright_ ure_functions_in_d/
When are pure functions coming to dmd ? -- Crowdnews.eu - a social news site based on sharing instead of voting. Follow me on CrowdNews http://crowdnews.eu/users/addGuide/42/
Sep 22 2008
Knud Soerensen wrote:When are pure functions coming to dmd ?
They're about half-implemented. Given the unexpected huge interest in this, I'll have to bump up the priority!
Sep 22 2008
Walter Bright Wrote:Knud Soerensen wrote:When are pure functions coming to dmd ?
They're about half-implemented. Given the unexpected huge interest in this, I'll have to bump up the priority!
Cool. That with TLS and a GC that doesn't block all threads and I'm switching to D2.
Sep 22 2008
Walter:http://www.reddit.com/r/programming/comments/72r6q/walter_bright_pure_functions_in_d/
It's an interesting read, a little refinement of things we have already started discussing. This page shows that gcc too has the "pure" attribute, for the same purpose (but the GCC compiler has to trust the programmer much more): http://gcc.gnu.org/onlinedocs/gcc-4.3.0//gcc/Function-Attributes.html(Invariant means immutable.)<
This specification, near the top of the article, that tells that a word means something else is a WARNING SIGN large as a wall that tells that that name is wrong and it has to change. Now I think D2 will sooner of later have to use the "immutable" word instead, as Python and Java communities too use.Parameters to a pure function can be mutable, but calls cannot be cached or executed asynchronously if the arguments contain any references to mutable data.<
I don't understand how can such function be pure.A pure function can throw an exception (purity does not imply nothrow).<
At the moment I think this the trickier decision of the whole pure stuff. This has to be chosen wisely, because a function that can throw isn't really pure. The situation is messy. It may be better for pure functions to never throw exceptions... This topic needs more thinking, with the help from the people of the functional crowd (Lambda the Ultimate) because otherwise there's a high risk of creating half-baked stuff as the closures in D2 (lot of people want a way to not allocate data on the heap. I think this can be solved making them allocate data on the heap by default, unless the programmer explicitly chooses otherwise, for example adding a "scope" statement before the closure). int x = foo(3) + bar[foo(3)]; need only execute foo(3) once. If foo can throw exceptions that's not true anymore, I think.They can be hot swapped (meaning replaced at runtime), because they do not rely on any global initialization or termination state.<
This sounds true and interesting, but what can it be used/useful for? ----------- Bill Baxter:Glad to see that "const" args will be OK for pure functions, too. Not just "invariant" as was originally announced. That will certainly make pure functions in D much more useful.<
I don't understand (probably because I don't remember what 'const' exactly means here). millstone:Also, what if a parameter to a pure function is marked lazy?<
Interesting question. I think the lazy callable can be accepted (at compile time) only if it wraps an immutable value or a pure function. Bye, bearophile
Sep 22 2008
bearophile Wrote:(Invariant means immutable.)<
This specification, near the top of the article, that tells that a word means something else is a WARNING SIGN large as a wall that tells that that name is wrong and it has to change. Now I think D2 will sooner of later have to use the "immutable" word instead, as Python and Java communities too use.
That's exactly what went through my head when I saw this line of the article and I agree 100%, invariant needs to change to immutable in D2 before it becomes too late.A pure function can throw an exception (purity does not imply nothrow).<
Since this wasn't touched on in the article, I want to point out that Haskell allows "pure functions" to throw exceptions, but not catch them. We need the same limitation in D2 pure functions -- since the exceptions can only be caught in impure code, it's OK that the pure function threw instead of returning. What can't happen is we can't have pure functions catching exceptions, since they can then return a different value when, for example, an out-of-memory exception is thrown. -- Brian
Sep 22 2008
Brian Palmer wrote:bearophile Wrote:(Invariant means immutable.)<
That's exactly what went through my head when I saw this line of the article and I agree 100%, invariant needs to change to immutable in D2 before it becomes too late.
I completely agree. In every document/article I've read about the const system in D and where it says "invariant" it's explained to mean immutable, so why not just change the keyword.
Sep 22 2008
Brian Palmer:Since this wasn't touched on in the article, I want to point out that Haskell allows "pure functions" to throw exceptions, but not catch them. We need the same limitation in D2 pure functions -- since the exceptions can only be caught in impure code, it's OK that the pure function threw instead of returning. What can't happen is we can't have pure functions catching exceptions, since they can then return a different value when, for example, an out-of-memory exception is thrown.
This is quite interesting and it has some consequences. So a pure function can call another pure function only if the second one can't throw? Pure functions can be recursive (because if the stack finishes all the program stops with an error). So recursive pure functions can't throw exceptions? :-) Now I am sure that some knowledge of Haskell may help the design of the functional parts of D. ---------------- Walter says on Reddit:There's also nothrow, which would specify that the function also did not throw.<
But then you have to write function signatures as: nothrow pure int foo(int x, const int[] a) {...} That looks a bit long to write. ---------------- Walter:Functional programming capability is an exciting addition to imperative programming languages.<
I agree. A general comment: functional programming (like OOP) doesn't work in vacuum. Computer languages are like ecologies of many interacting syntaxes. So for some functional programming capability to "survive" well in one of such ecologies several other parts of that ecology have to be fit. To make the usage of FP capabilities handy/good enough to be actually used several other things in a compiler/language have to be fit, like: - Good closures - A very compact syntax for delegates/closures. In Haskell and other FP languages you can see how you can even turn operators into functions in a very short space. - Some type inference, because types tend to become quite convoluted, etc. FP languages have type systems that are much more complex than the currend D one (you don't need to look at Haskell type system, eve, lesser FP languages fit the bill). - Some higher-order functions with a short and flexible syntax, like folds, maps, filters you can find in most FP languages, list comprehensions, etc that in various forms you can find in Python, Ruby, Haskell, etc. - Good management of operator precedence. - Good management of lazy iterables, for example like the presence of the len() function of my libs that returns the length of both eager and lazy iterables, etc. D already has some/part of those things and I am not saying that you need all of them to program in a functional style. In truth you can probably have FP even without all of them. But then the functional programming itself become awkward, feels unnatural, or that requires too much code, and in the end it becomes used very little. So I can already use something like (this is just for show, not working): map((int i){ return op(i)+op(i); }, xfilter((int i){ ....}, iterable))); but it's too much unreadable, so it becomes worse than a normal for loop. While with a Python (or Haskell, or even Ruby) syntax you can do the same thing in a readable enough way, so programmers feel encouraged to actually use functional constructs. This is why syntax matters. Note that for a short syntax to work, the compiler may need to perform more type inferencing, and this in turn may require a a bit more powerful type system... So to make FP in D actually usable a more powerful type system (plus some shorter/sugared syntax) may be needed. I don't know, we'll see. Bye, bearophile
Sep 22 2008
bearophile <bearophileHUGS lycos.com> wrote:Since this wasn't touched on in the article, I want to point out that Haskell allows "pure functions" to throw exceptions, but not catch them.
This is quite interesting and it has some consequences. So a pure function can call another pure function only if the second one can't throw?
I cannot see how this follows. If a function calls another function that may throw, it doesn't automatically make it catch. So the call may be of any depth, and an exception may be thrown at any level. You just not allowed to try/catch, nor various forms of scope.
Sep 22 2008
Sergey Gromov Wrote:bearophile <bearophileHUGS lycos.com> wrote:Since this wasn't touched on in the article, I want to point out that Haskell allows "pure functions" to throw exceptions, but not catch them.
This is quite interesting and it has some consequences. So a pure function can call another pure function only if the second one can't throw?
I cannot see how this follows. If a function calls another function that may throw, it doesn't automatically make it catch. So the call may be of any depth, and an exception may be thrown at any level. You just not allowed to try/catch, nor various forms of scope.
Yes, Sergey has it right here.
Sep 22 2008
bearophile:- Good closures - A very compact syntax for delegates/closures. In Haskell and other FP languages you can see how you can even turn operators into functions in a very short space.
In that list I have missed a quite important thing: the compiler has to know those syntax constructs and needs to know ways to simplify them, so they become compiled efficiently, otherwise the programmer of a system language will not be encouraged to use them in some parts of the code. The Haskell compiler has several ways to simplify and compile the code in an efficient way. Other compilers like Scheme Stalin show that there are lot of things that can be done to produce efficient assembly from FP-style code. Bye, bearophile
Sep 22 2008
bearophile a écrit :Brian Palmer:Since this wasn't touched on in the article, I want to point out that Haskell allows "pure functions" to throw exceptions, but not catch them. We need the same limitation in D2 pure functions -- since the exceptions can only be caught in impure code, it's OK that the pure function threw instead of returning. What can't happen is we can't have pure functions catching exceptions, since they can then return a different value when, for example, an out-of-memory exception is thrown.
Mmmm, "pure" functions are not pure with respect to 'out-of-memory' exceptions ie depending on the amount of memory available a pure function might return a value or might return an out-of-memory exception.. IMHO this must be the same in Haskell: I don't see how it could be different.. But this is okay: programs cannot be expected to have the same behaviour when there is or isn't free memory available. So pure functions are not fully identical to math pure functions in this respect.. BR, RenoXThis is quite interesting and it has some consequences. So a pure function can call another pure function only if the second one can't throw? Pure functions can be recursive (because if the stack finishes all the program stops with an error). So recursive pure functions can't throw exceptions? :-) Now I am sure that some knowledge of Haskell may help the design of the functional parts of D. ---------------- Walter says on Reddit:There's also nothrow, which would specify that the function also did not throw.<
But then you have to write function signatures as: nothrow pure int foo(int x, const int[] a) {...} That looks a bit long to write. ---------------- Walter:Functional programming capability is an exciting addition to imperative programming languages.<
I agree. A general comment: functional programming (like OOP) doesn't work in vacuum. Computer languages are like ecologies of many interacting syntaxes. So for some functional programming capability to "survive" well in one of such ecologies several other parts of that ecology have to be fit. To make the usage of FP capabilities handy/good enough to be actually used several other things in a compiler/language have to be fit, like: - Good closures - A very compact syntax for delegates/closures. In Haskell and other FP languages you can see how you can even turn operators into functions in a very short space. - Some type inference, because types tend to become quite convoluted, etc. FP languages have type systems that are much more complex than the currend D one (you don't need to look at Haskell type system, eve, lesser FP languages fit the bill). - Some higher-order functions with a short and flexible syntax, like folds, maps, filters you can find in most FP languages, list comprehensions, etc that in various forms you can find in Python, Ruby, Haskell, etc. - Good management of operator precedence. - Good management of lazy iterables, for example like the presence of the len() function of my libs that returns the length of both eager and lazy iterables, etc. D already has some/part of those things and I am not saying that you need all of them to program in a functional style. In truth you can probably have FP even without all of them. But then the functional programming itself become awkward, feels unnatural, or that requires too much code, and in the end it becomes used very little. So I can already use something like (this is just for show, not working): map((int i){ return op(i)+op(i); }, xfilter((int i){ ....}, iterable))); but it's too much unreadable, so it becomes worse than a normal for loop. While with a Python (or Haskell, or even Ruby) syntax you can do the same thing in a readable enough way, so programmers feel encouraged to actually use functional constructs. This is why syntax matters. Note that for a short syntax to work, the compiler may need to perform more type inferencing, and this in turn may require a a bit more powerful type system... So to make FP in D actually usable a more powerful type system (plus some shorter/sugared syntax) may be needed. I don't know, we'll see. Bye, bearophile
Sep 26 2008
I find invariant more natural and immutable more clumsy. On the other hand, why not make invariant the default and be done with it. The trend will go in that direction, the introduction of the entire const correctness stuff is an indication of where things are going. Better optimizable and safe by default than "invariant-with-effort". Bent "Brian Palmer" <d brian.codekitchen.net> skrev i meddelelsen news:gb89pv$1l31$1 digitalmars.com...bearophile Wrote:(Invariant means immutable.)<
This specification, near the top of the article, that tells that a word means something else is a WARNING SIGN large as a wall that tells that that name is wrong and it has to change. Now I think D2 will sooner of later have to use the "immutable" word instead, as Python and Java communities too use.
That's exactly what went through my head when I saw this line of the article and I agree 100%, invariant needs to change to immutable in D2 before it becomes too late.A pure function can throw an exception (purity does not imply nothrow).<
Since this wasn't touched on in the article, I want to point out that Haskell allows "pure functions" to throw exceptions, but not catch them. We need the same limitation in D2 pure functions -- since the exceptions can only be caught in impure code, it's OK that the pure function threw instead of returning. What can't happen is we can't have pure functions catching exceptions, since they can then return a different value when, for example, an out-of-memory exception is thrown. -- Brian
Sep 24 2008
Bent Rasmussen:I find invariant more natural and immutable more clumsy.
Yet, it seems that's the right terminology: http://en.wikipedia.org/wiki/Immutable_objectOn the other hand, why not make invariant the default and be done with it. The trend will go in that direction
I agree that this seems where the trend goes, but: - I think you can't change the language too much. D is too much based on mutable data to change it all now. So I think it may be better to invent a new language that uses mostly immutable data (Scala?) instead of turning D inside-out. I presume Walter too will invent other languages when D is finished, or even along the way. - While today some languages show the advantages of immutable data, there's probably space still for a niche with a language with mostly mutable data structures. D is for that niche (today that niche is very large but it may shrink in the following years). Bye, bearophile
Sep 24 2008
I agree that this seems where the trend goes, but: - I think you can't change the language too much. D is too much based on mutable data to change it all now. So I think it may be better to invent a new language that uses mostly immutable data (Scala?) instead of turning D inside-out. I presume Walter too will invent other languages when D is finished, or even along the way. - While today some languages show the advantages of immutable data, there's probably space still for a niche with a language with mostly mutable data structures. D is for that niche (today that niche is very large but it may shrink in the following years).
It's not about either or. The philosphy of D, says that there is no religion. Nevertheless there is still bias. The bias is whitnessed by public/private-by-default, variant/const/invariant-by-default, pure/impure-by-default and shared/unshared-by-default. I say: move defaults towards the sensible future. This is not the same as a religious outlawing of features. There is still D1 for the past. Maybe an IDE could be made to "reverse" the default so it looks like the opposite.Bye, bearophile
Sep 24 2008
- for the record: public counts as sensible: in a safe world there's (almost) no reason to hide :-) Bent "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> skrev i meddelelsen news:gbedek$mvf$1 digitalmars.com...I agree that this seems where the trend goes, but: - I think you can't change the language too much. D is too much based on mutable data to change it all now. So I think it may be better to invent a new language that uses mostly immutable data (Scala?) instead of turning D inside-out. I presume Walter too will invent other languages when D is finished, or even along the way. - While today some languages show the advantages of immutable data, there's probably space still for a niche with a language with mostly mutable data structures. D is for that niche (today that niche is very large but it may shrink in the following years).
It's not about either or. The philosphy of D, says that there is no religion. Nevertheless there is still bias. The bias is whitnessed by public/private-by-default, variant/const/invariant-by-default, pure/impure-by-default and shared/unshared-by-default. I say: move defaults towards the sensible future. This is not the same as a religious outlawing of features. There is still D1 for the past. Maybe an IDE could be made to "reverse" the default so it looks like the opposite.Bye, bearophile
Sep 24 2008
Bent Rasmussen a écrit :- for the record: public counts as sensible: in a safe world there's (almost) no reason to hide :-)
I disagree: public isn't about being safe and private about being hidden, it's a "making part of the interface" choice that I'll have to support till the end of times choice. There are quite a few maintainability guides which advise to makes small well-defined interface, so in this mindset public shouldn't be the default. RenoXBent "Bent Rasmussen" <IncredibleShrinkingSphere Gmail.com> skrev i meddelelsen news:gbedek$mvf$1 digitalmars.com...I agree that this seems where the trend goes, but: - I think you can't change the language too much. D is too much based on mutable data to change it all now. So I think it may be better to invent a new language that uses mostly immutable data (Scala?) instead of turning D inside-out. I presume Walter too will invent other languages when D is finished, or even along the way. - While today some languages show the advantages of immutable data, there's probably space still for a niche with a language with mostly mutable data structures. D is for that niche (today that niche is very large but it may shrink in the following years).
It's not about either or. The philosphy of D, says that there is no religion. Nevertheless there is still bias. The bias is whitnessed by public/private-by-default, variant/const/invariant-by-default, pure/impure-by-default and shared/unshared-by-default. I say: move defaults towards the sensible future. This is not the same as a religious outlawing of features. There is still D1 for the past. Maybe an IDE could be made to "reverse" the default so it looks like the opposite.Bye, bearophile
Sep 26 2008
"bearophile" wroteWalter:Parameters to a pure function can be mutable, but calls cannot be cached or executed asynchronously if the arguments contain any references to mutable data.<
I don't understand how can such function be pure.
It can't be. I think Walter made a mistake there. Otherwise, you could pass data that another thread changes while in the middle of using it. Maybe he meant that a pure function can *return* mutable data? Then 'new' could be considered pure? Another possibility is that Walter is assuming the shared/unshared paradigm is in place. Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread. Who knows what he was thinking ;) But the current article statement is definitely wrong without clarification. -Steve
Sep 22 2008
Steven Schveighoffer wrote:Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread.
I'm almost certain this is the intended behavior, with the addition that you can also call that same pure function from an unpure one, only then, the compiler will treat the function as being unpure. This is the gist of the "partially pure"/"contextually pure" idea: a function is considered pure or not dependent on the immutability of the arguments with which it's called. This consideration "happens" on every call. Since the optimizations to pure functions are made on the call, and not on the body of the function, this is perfectly ok. I don't see any other behavior that isn't either broken, or more limited in functionality. Also note that in the case where the given (contextually) pure "foo" function is called from a pure function, the fact that foo is called from a pure function only guarantees that the arguments are not changed by anyone else when foo executes, but foo must still be treated as unpure. Example: pure void foo(int* iptr) { (*iptr)++; // side effect } pure int func() { int a = 1; foo(&a); // side-effect, cannot optimize this call foo(&a); // side-effect, cannot optimize this call return a; } // Yet func is allways pure. -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Sep 23 2008
"Bruno Medeiros" wroteSteven Schveighoffer wrote:Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread.
I'm almost certain this is the intended behavior, with the addition that you can also call that same pure function from an unpure one, only then, the compiler will treat the function as being unpure. This is the gist of the "partially pure"/"contextually pure" idea: a function is considered pure or not dependent on the immutability of the arguments with which it's called. This consideration "happens" on every call. Since the optimizations to pure functions are made on the call, and not on the body of the function, this is perfectly ok. I don't see any other behavior that isn't either broken, or more limited in functionality.
One of the benefits that Walter and Andrei's original purity plan provided was that you could always assume that pure functions did not have to worry about threading issues. I think allowing a pure function that takes mutable arguments to be callable from an unpure function removes that benefit. I hope this isn't the case. Of course, if shared/unshared is implemented, and pure functions are only allowed to be passed 'unshared' mutable data, then the benefit is still on. I'm just unclear on what Walter is planning. I admit I didn't read the whole article, I just saw that quote and thought 'hm... that looks wrong'.Also note that in the case where the given (contextually) pure "foo" function is called from a pure function, the fact that foo is called from a pure function only guarantees that the arguments are not changed by anyone else when foo executes, but foo must still be treated as unpure. Example: pure void foo(int* iptr) { (*iptr)++; // side effect } pure int func() { int a = 1; foo(&a); // side-effect, cannot optimize this call foo(&a); // side-effect, cannot optimize this call return a; } // Yet func is allways pure.
I agree with you, partially pure functions can be called from pure functions with limited optimization. But if you allow foo to be called from an unpure function you could have this problem: int func2() { static int a = 1; foo(&a); } Now, if 2 threads are calling func2, you have race conditions and threading issues in foo, which seems to be a major concern that W/A were trying to address. And I hope they do address it, it was the one huge benefit I saw from pure functions. -Steve
Sep 23 2008
Steven Schveighoffer wrote:"Bruno Medeiros" wroteSteven Schveighoffer wrote:Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread.
you can also call that same pure function from an unpure one, only then, the compiler will treat the function as being unpure. This is the gist of the "partially pure"/"contextually pure" idea: a function is considered pure or not dependent on the immutability of the arguments with which it's called. This consideration "happens" on every call. Since the optimizations to pure functions are made on the call, and not on the body of the function, this is perfectly ok. I don't see any other behavior that isn't either broken, or more limited in functionality.
One of the benefits that Walter and Andrei's original purity plan provided was that you could always assume that pure functions did not have to worry about threading issues. I think allowing a pure function that takes mutable arguments to be callable from an unpure function removes that benefit. I hope this isn't the case. Of course, if shared/unshared is implemented, and pure functions are only allowed to be passed 'unshared' mutable data, then the benefit is still on. I'm just unclear on what Walter is planning. I admit I didn't read the whole article, I just saw that quote and thought 'hm... that looks wrong'.Also note that in the case where the given (contextually) pure "foo" function is called from a pure function, the fact that foo is called from a pure function only guarantees that the arguments are not changed by anyone else when foo executes, but foo must still be treated as unpure. Example: pure void foo(int* iptr) { (*iptr)++; // side effect } pure int func() { int a = 1; foo(&a); // side-effect, cannot optimize this call foo(&a); // side-effect, cannot optimize this call return a; } // Yet func is allways pure.
I agree with you, partially pure functions can be called from pure functions with limited optimization. But if you allow foo to be called from an unpure function you could have this problem: int func2() { static int a = 1; foo(&a); } Now, if 2 threads are calling func2, you have race conditions and threading issues in foo, which seems to be a major concern that W/A were trying to address. And I hope they do address it, it was the one huge benefit I saw from pure functions. -Steve
Yes, you can have race and threading issues in foo with that call. But what is the alternative? In the first pure system (in andrei's presentation) that call would not be allowed. So what you would do? You'd have to write another function just like foo (the same code), but that is not marked pure, and use that. But you'd still have the same synchronization problems. If you don't want to have those issues, write a foo function that takes invariant parameters. The partially pure functions (functions with mutable parameters), which basically have localized side-effects and are deterministic when called from "really-pure" functions, are not there to provide the full effects of really-pure functions. They are just a convenience for the writing the really-pure functions. (Also, I'd reckon most static/global functions will be partially pure.) -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Sep 24 2008
"Bruno Medeiros" wroteSteven Schveighoffer wrote:"Bruno Medeiros" wroteSteven Schveighoffer wrote:Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread.
you can also call that same pure function from an unpure one, only then, the compiler will treat the function as being unpure. This is the gist of the "partially pure"/"contextually pure" idea: a function is considered pure or not dependent on the immutability of the arguments with which it's called. This consideration "happens" on every call. Since the optimizations to pure functions are made on the call, and not on the body of the function, this is perfectly ok. I don't see any other behavior that isn't either broken, or more limited in functionality.
One of the benefits that Walter and Andrei's original purity plan provided was that you could always assume that pure functions did not have to worry about threading issues. I think allowing a pure function that takes mutable arguments to be callable from an unpure function removes that benefit. I hope this isn't the case. Of course, if shared/unshared is implemented, and pure functions are only allowed to be passed 'unshared' mutable data, then the benefit is still on. I'm just unclear on what Walter is planning. I admit I didn't read the whole article, I just saw that quote and thought 'hm... that looks wrong'.Also note that in the case where the given (contextually) pure "foo" function is called from a pure function, the fact that foo is called from a pure function only guarantees that the arguments are not changed by anyone else when foo executes, but foo must still be treated as unpure. Example: pure void foo(int* iptr) { (*iptr)++; // side effect } pure int func() { int a = 1; foo(&a); // side-effect, cannot optimize this call foo(&a); // side-effect, cannot optimize this call return a; } // Yet func is allways pure.
I agree with you, partially pure functions can be called from pure functions with limited optimization. But if you allow foo to be called from an unpure function you could have this problem: int func2() { static int a = 1; foo(&a); } Now, if 2 threads are calling func2, you have race conditions and threading issues in foo, which seems to be a major concern that W/A were trying to address. And I hope they do address it, it was the one huge benefit I saw from pure functions. -Steve
Yes, you can have race and threading issues in foo with that call. But what is the alternative? In the first pure system (in andrei's presentation) that call would not be allowed. So what you would do? You'd have to write another function just like foo (the same code), but that is not marked pure, and use that. But you'd still have the same synchronization problems. If you don't want to have those issues, write a foo function that takes invariant parameters. The partially pure functions (functions with mutable parameters), which basically have localized side-effects and are deterministic when called from "really-pure" functions, are not there to provide the full effects of really-pure functions. They are just a convenience for the writing the really-pure functions. (Also, I'd reckon most static/global functions will be partially pure.)
It creates a definitive line which can be used to determine whether or not I need to worry about threading. Having the compiler enforce this I see as a huge benefit. I was hoping to keep that line. If the compiler enforces that the parameters to foo must be local, either by implementing the shared/unshared paradigm or only allowing calling from other pure functions, then the line still exists. It appears that that is the case, as evidenced from other posts. -Steve
Sep 24 2008
bearophile wrote:They can be hot swapped (meaning replaced at runtime), because they do not rely on any global initialization or termination state.<
This sounds true and interesting, but what can it be used/useful for?
I've heard mention many times that languages like Erlang allow hot swapping meaning the software can be upgraded without bringing the system to a halt first.
Sep 22 2008
Denis Koroskin wrote:On Tue, 23 Sep 2008 02:24:10 +0400, Walter Bright <newshound1 digitalmars.com> wrote:bearophile wrote:They can be hot swapped (meaning replaced at runtime), because they do not rely on any global initialization or termination state.<
I've heard mention many times that languages like Erlang allow hot swapping meaning the software can be upgraded without bringing the system to a halt first.
Yes, Java has some support of hot-swapping, too. Imagine you have a MMORPG server. Applying a patch or adding some additional content is a daily event. Doing so without disconnecting the people (especially if there are thousands of player online) is desirable but hardly available in C/C++.
I did that with an IRC bot a while back. Just build a new executable, halt all your running tasks, dump the system state to a file (*including socket handles*), use the exec system call to replace the process with the new executable, and read the system state back, replacing handles as you go. No dropped connections.
Sep 23 2008
downs, el 24 de septiembre a las 08:52 me escribiste:Denis Koroskin wrote:On Tue, 23 Sep 2008 02:24:10 +0400, Walter Bright <newshound1 digitalmars.com> wrote:bearophile wrote:They can be hot swapped (meaning replaced at runtime), because they do not rely on any global initialization or termination state.<
I've heard mention many times that languages like Erlang allow hot swapping meaning the software can be upgraded without bringing the system to a halt first.
Yes, Java has some support of hot-swapping, too. Imagine you have a MMORPG server. Applying a patch or adding some additional content is a daily event. Doing so without disconnecting the people (especially if there are thousands of player online) is desirable but hardly available in C/C++.
I did that with an IRC bot a while back. Just build a new executable, halt all your running tasks, dump the system state to a file (*including socket handles*), use the exec system call to replace the process with the new executable, and read the system state back, replacing handles as you go. No dropped connections.
Using dynamic libraries with dlopen can be useful for hot-swapping too. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- El trabajo no sólo tara, sino que tarará y seguirá tararando. -- Ricardo Vaporeso
Sep 24 2008
downs wrote:Just build a new executable, halt all your running tasks, dump the system state to a file (*including socket handles*), use the exec system call to replace the process with the new executable, and read the system state back, replacing handles as you go. No dropped connections.
I've done that with C/C++ code before. The trouble is finding *all* of the state that matters in order to save/restore it. It can be done, but it is tedious and very error prone. But with pure functions, it's a no-brainer.
Sep 26 2008
On Tue, 23 Sep 2008 02:12:58 +0400, Steven Schveighoffer <schveiguy yahoo.com> wrote:"bearophile" wroteWalter:Parameters to a pure function can be mutable, but calls cannot be cached or executed asynchronously if the arguments contain any references to mutable data.<
I don't understand how can such function be pure.
It can't be. I think Walter made a mistake there. Otherwise, you could pass data that another thread changes while in the middle of using it. Maybe he meant that a pure function can *return* mutable data? Then 'new' could be considered pure? Another possibility is that Walter is assuming the shared/unshared paradigm is in place. Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread. Who knows what he was thinking ;) But the current article statement is definitely wrong without clarification. -Steve
I think he meant both:Pure functions do not require synchronization for use by multiple threads, because their data is all either *thread local* or immutable.
Given that an implicit unshared attribute is attached to mutable variable arguments such functions are definitely pure: pure void inplace_tolower(char[] str); // yes! pure Foo bar() { char[] str = "HELLO".dup; inplace_tolower(str); ... }
Sep 22 2008
On Tue, 23 Sep 2008 02:24:10 +0400, Walter Bright <newshound1 digitalmars.com> wrote:bearophile wrote:They can be hot swapped (meaning replaced at runtime), because they do not rely on any global initialization or termination state.<
I've heard mention many times that languages like Erlang allow hot swapping meaning the software can be upgraded without bringing the system to a halt first.
Yes, Java has some support of hot-swapping, too. Imagine you have a MMORPG server. Applying a patch or adding some additional content is a daily event. Doing so without disconnecting the people (especially if there are thousands of player online) is desirable but hardly available in C/C++.
Sep 22 2008
On Wed, 24 Sep 2008 08:25:59 +0400, Steven Schveighoffer <schveiguy yahoo.com> wrote:"Bruno Medeiros" wroteSteven Schveighoffer wrote:Another possibility is that pure functions that accept mutable parameters can only be called from other pure functions, therefore you are guaranteed that the data is not being used in any other thread.
I agree with you, partially pure functions can be called from pure functions with limited optimization. But if you allow foo to be called from an unpure function you could have this problem: int func2() { static int a = 1; foo(&a); } Now, if 2 threads are calling func2, you have race conditions and threading issues in foo, which seems to be a major concern that W/A were trying to address. And I hope they do address it, it was the one huge benefit I saw from pure functions. -Steve
No race conditions if "a" is unshared and Walter mentioned that pure functions allowed thread-local mutable arguments only.
Sep 24 2008
On Wed, 24 Sep 2008 13:15:12 +0100, Leandro Lucarella <llucax gmail.com> wrote:downs, el 24 de septiembre a las 08:52 me escribiste:Denis Koroskin wrote:On Tue, 23 Sep 2008 02:24:10 +0400, Walter Bright <newshound1 digitalmars.com> wrote:bearophile wrote:They can be hot swapped (meaning replaced at runtime), because they do not rely on any global initialization or termination state.<
I've heard mention many times that languages like Erlang allow hot swapping meaning the software can be upgraded without bringing the system to a halt first.
Yes, Java has some support of hot-swapping, too. Imagine you have a MMORPG server. Applying a patch or adding some additional content is a daily event. Doing so without disconnecting
people (especially if there are thousands of player online) is
but hardly available in C/C++.
I did that with an IRC bot a while back. Just build a new executable, halt all your running tasks, dump the system state to a file (*including socket handles*), use the exec system call to replace the process with the new executable, and read the system state back, replacing handles as you go. No dropped connections.
Using dynamic libraries with dlopen can be useful for hot-swapping too.
Also take a look at the purple book "Advanced C++ Programming" by Coplien.
Sep 25 2008
Walter:There will be no reasonable way for the programmer who expects a function to be pure, to see if it actually is pure. If he does check (which might be arbitrarilly difficult to do) and it is not pure, he has no reasonable way to determine why the compiler thought it was impure.<
Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents. Bye, bearophile
Sep 22 2008
On Mon, Sep 22, 2008 at 09:58:13AM -0400, bearophile wrote:Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents.
"He" is technically proper English. When the gender is not known or doesn't matter, you use the male pronouns.Bye, bearophile
-- Adam D. Ruppe http://arsdnet.net
Sep 22 2008
Adam D. Ruppe wrote:On Mon, Sep 22, 2008 at 09:58:13AM -0400, bearophile wrote:Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents.
"He" is technically proper English. When the gender is not known or doesn't matter, you use the male pronouns.
Or the female pronouns. Common practice these days is to pick a gender for a particular section, but it's even accepted to switch genders in different sections so long as doing so isn't confusing to the reader. Sean
Sep 22 2008
Sean Kelly wrote:Adam D. Ruppe wrote:On Mon, Sep 22, 2008 at 09:58:13AM -0400, bearophile wrote:Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents.
"He" is technically proper English. When the gender is not known or doesn't matter, you use the male pronouns.
Or the female pronouns. Common practice these days is to pick a gender for a particular section, but it's even accepted to switch genders in different sections so long as doing so isn't confusing to the reader. Sean
It's also common, and has been for a few centuries, to use "they" in these situations. There was a prescriptivist movement not too long ago trying to deprecate that use of "they", but it hasn't been terribly successful.
Sep 22 2008
Christopher Wright wrote:Sean Kelly wrote:Adam D. Ruppe wrote:On Mon, Sep 22, 2008 at 09:58:13AM -0400, bearophile wrote:Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents.
"He" is technically proper English. When the gender is not known or doesn't matter, you use the male pronouns.
Or the female pronouns. Common practice these days is to pick a gender for a particular section, but it's even accepted to switch genders in different sections so long as doing so isn't confusing to the reader.
It's also common, and has been for a few centuries, to use "they" in these situations. There was a prescriptivist movement not too long ago trying to deprecate that use of "they", but it hasn't been terribly successful.
True enough. And I do use "they" from time to time, but I think it tends to be somewhat off-putting if used extensively. Sean
Sep 22 2008
Adam D. Ruppe wrote:On Mon, Sep 22, 2008 at 09:58:13AM -0400, bearophile wrote:Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents.
"He" is technically proper English. When the gender is not known or doesn't matter, you use the male pronouns.Bye, bearophile
But then how else do you show that you are politically hip and sensitive to PC issues?
Sep 22 2008
Saaa Wrote:sie hir
Shi/hir/hirself are for hermaphrodite people, so I think they aren't much fit there. Bye, bearophile
Sep 22 2008
Lol, didn't know damn furries stole them. http://furry.wikia.com/wiki/HermaphroditeSaaa Wrote:sie hir
Shi/hir/hirself are for hermaphrodite people, so I think they aren't much fit there. Bye, bearophile
Sep 23 2008
Reply to bearophile,Walter:There will be no reasonable way for the programmer who expects a function to be pure, to see if it actually is pure. If he does check (which might be arbitrarilly difficult to do) and it is not pure, he has no reasonable way to determine why the compiler thought it was impure.<
language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents. Bye, bearophile
Ahh. One Of my pet peeves about the English language. Pronouns!. We have no gender neutral third person singular pronoun ('they' is plural and 'it' is an insult). But the fun one is second person plural. Bet all you'all can't tell me what the best one is... Oh Crud, just blew that one. :(
Sep 22 2008
I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!Just a little note: those "he" refer to a male programmer. The D language has a small community, so each person is precious, so it's better to not show sexual discrimination, and try to use a more sexual neutral language in public articles/documents. Bye, bearophile
Ahh. One Of my pet peeves about the English language. Pronouns!. We have no gender neutral third person singular pronoun ('they' is plural and 'it' is an insult). But the fun one is second person plural. Bet all you'all can't tell me what the best one is... Oh Crud, just blew that one. :(
Sep 23 2008
Victor Tyurin:I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness.
While adult women of other cultures/nations may be annoyed by your words. Bye, bearophile
Sep 23 2008
We can't please every nation...
What if my nation/religion have "Dee" sacred word?
Should we rename D language to {some_GUID}, to never annoy any
nation/religion/etc?
Who cares about that feministic PC?
USA and Western Europe?
All ex-USSR space don't cares, most South America nations, Eastern
Europe too, i bet..
China, Japan, Korea - do trey care about this? I think, no...
If some person, while reading technical texts, tries to find there some
"discrimination", i think, he/she will find it anyway.
"The pig will find the mud, anyway" - this is my (bad) translation of
Russian proverb.
Don't be a PC-extremist!
If you will follow that PC way, should you rewrite Holy Bible, for
example? Or, all pre-PC era writers, like Shakespeare, for example?
Victor Tyurin:
I'm sure that Russian girls-programmers just laugh when hear those
language perversions for sexual polit-correctness.
While adult women of other cultures/nations may be annoyed by your words.
Bye,
bearophile
Sep 24 2008
And, anyway, this feminist PC is USA-specific only (maybe, Europe too, not sure, but, anyway, not whole Europe). The person of other culture just can't respect those PC language rules properly, just because he don't knows those rules, and don't knows those modern American culture issues...We can't please every nation... What if my nation/religion have "Dee" sacred word? Should we rename D language to {some_GUID}, to never annoy any nation/religion/etc? Who cares about that feministic PC? USA and Western Europe?
Sep 24 2008
Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
I find the gender neutral part funny as well, however once in a while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
Sep 23 2008
BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
I find the gender neutral part funny as well, however once in a while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
Sep 23 2008
Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
I find it most interesting that four versions of "you" exist in hebrew, that are all combinations of "male/female" and "singular/plural".
Sep 23 2008
Ary Borenszweig wrote:Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
I find it most interesting that four versions of "you" exist in hebrew, that are all combinations of "male/female" and "singular/plural".
Isn't it like this in most languages? at least I know that Russian has both singular and plural. actually I think I read once that English had the same distinction as well but it got deprecated or something.
Sep 23 2008
"Yigal Chripun" wroteAry Borenszweig wrote:Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
I find it most interesting that four versions of "you" exist in hebrew, that are all combinations of "male/female" and "singular/plural".
Isn't it like this in most languages? at least I know that Russian has both singular and plural. actually I think I read once that English had the same distinction as well but it got deprecated or something.
Yes, in English version 2.023, gender specific 'you' was deprecated. If you wish to have a gender specific 'you', use enum: enum : you { she_you, he_you } -Steve
Sep 23 2008
Steven Schveighoffer wrote:"Yigal Chripun" wroteAry Borenszweig wrote:Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
that are all combinations of "male/female" and "singular/plural".
at least I know that Russian has both singular and plural. actually I think I read once that English had the same distinction as well but it got deprecated or something.
Yes, in English version 2.023, gender specific 'you' was deprecated. If you wish to have a gender specific 'you', use enum: enum : you { she_you, he_you } -Steve
that's a good one. but seriously, here's a Wikipedia quote for what I meant: "In standard English, you is both singular and plural; it always takes a verb form that originally marked the word as plural, such as you are. This was not always so. Early Modern English distinguished between the plural you and the singular thou. This distinction was lost in modern English due to the importation from France of a Romance linguistic feature which is commonly called the T-V distinction." there's also the "ye" form.
Sep 23 2008
Reply to Yigal,LOL! that's a good one. but seriously, here's a Wikipedia quote for what I meant: "In standard English, you is both singular and plural; it always takes a verb form that originally marked the word as plural, such as you are. This was not always so. Early Modern English distinguished between the plural you and the singular thou. This distinction was lost in modern English due to the importation from France of a Romance linguistic feature which is commonly called the T-V distinction."
IIRC that shows up in the King James bible and as foot notes in the NIV. (please ignore an non literary/linguistic aspects of that comment, One Theological thread a year is enough!)there's also the "ye" form.
There was a thread on that a while ago that brought up "ye" as a mangled version of the via the þ char that turned into y. http://en.wikipedia.org/wiki/Ye_(pronoun) :þ
Sep 23 2008
BCS wrote:Reply to Yigal,LOL! that's a good one. but seriously, here's a Wikipedia quote for what I meant: "In standard English, you is both singular and plural; it always takes a verb form that originally marked the word as plural, such as you are. This was not always so. Early Modern English distinguished between the plural you and the singular thou. This distinction was lost in modern English due to the importation from France of a Romance linguistic feature which is commonly called the T-V distinction."
IIRC that shows up in the King James bible and as foot notes in the NIV.
I don't know what NIV is. I know that Shakespeare used it and it was generally used as a less formal form. today, Ironically, it can be considered as _more_ formal because it is no longer in day-to-day use.(please ignore an non literary/linguistic aspects of that comment, One Theological thread a year is enough!)
sure thing ;) I totally agreethere's also the "ye" form.
There was a thread on that a while ago that brought up "ye" as a mangled version of the via the þ char that turned into y. http://en.wikipedia.org/wiki/Ye_(pronoun) :þ
Sep 24 2008
Reply to Yigal,I don't know what NIV is.
It's a modern bible translation. http://en.wikipedia.org/wiki/NIV
Sep 24 2008
Yigal Chripun wrote:Steven Schveighoffer wrote:"Yigal Chripun" wroteAry Borenszweig wrote:Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
that are all combinations of "male/female" and "singular/plural".
at least I know that Russian has both singular and plural. actually I think I read once that English had the same distinction as well but it got deprecated or something.
wish to have a gender specific 'you', use enum: enum : you { she_you, he_you } -Steve
that's a good one. but seriously, here's a Wikipedia quote for what I meant: "In standard English, you is both singular and plural; it always takes a verb form that originally marked the word as plural, such as you are. This was not always so. Early Modern English distinguished between the plural you and the singular thou. This distinction was lost in modern English due to the importation from France of a Romance linguistic feature which is commonly called the T-V distinction." there's also the "ye" form.
"Thou" maybe dead in written English, but it is still there in the spoken (at least around my neck o' woods.) "What is tha doing" and "tha is gonna be late" for example (somewhere else it might still be closer to "thou" in pronunciation.) Use of "thy" or "thi" (second person possessive pronoun as in "what as tha done with thi hair?") might also still be heard. A...
Sep 24 2008
Reply to Alix,(at least around my neck o' woods.)
Where's that? :)
Sep 24 2008
BCS wrote:Reply to Alix,(at least around my neck o' woods.)
Where's that? :)
The North Riding of the county that is Yorkshire. A...
Sep 24 2008
Alix Pexton Wrote:BCS wrote:Reply to Alix,(at least around my neck o' woods.)
Where's that? :)
The North Riding of the county that is Yorkshire. A...
Or you could just watch "The Last of the Summer Wine"... ;-) Paul
Sep 25 2008
Paul D. Anderson wrote:Alix Pexton Wrote:BCS wrote:Reply to Alix,(at least around my neck o' woods.)
A...
Or you could just watch "The Last of the Summer Wine"... ;-) Paul
Not since I was about 12 ^^ A...
Sep 25 2008
Alix Pexton wrote:"Thou" maybe dead in written English, but it is still there in the spoken (at least around my neck o' woods.) "What is tha doing" and "tha is gonna be late" for example (somewhere else it might still be closer to "thou" in pronunciation.) Use of "thy" or "thi" (second person possessive pronoun as in "what as tha done with thi hair?") might also still be heard. A...
I think I'm in love.
Sep 24 2008
Reply to Ary,Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
hebrew, that are all combinations of "male/female" and "singular/plural".
I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
Sep 23 2008
BCS Wrote:I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
FWIW, your list isn't long enough -- Maori (along with most other Polynesian languages) has a dual case as well -- singular/dual/plural. The language also distinguishes between the inclusive and exclusive use of "we" -- including or excluding the person being spoken to. "We're going to the baseball game" (And you're not!) vs. "We should get together sometime." (You and I should get together.) You also overlooked the reflexive pronouns -- myself, ourselves, itself, themselves, etc. English can be a little ragged in that area, again with regard to gender. If a person of indeterminate gender should take some reflexive action does he/she do it himself? herself? itself? themself? -- Even the otherwise servicable "they" doesn't work since it is invariable plural, "themselves", when used reflexively. And interrogatives are sometimes considered pronouns -- who/whom, etc. Do even the artificial languages (Esperanto, LogLan, etc.) fill all these slots?? Paul
Sep 23 2008
Paul D. Anderson Wrote:BCS Wrote:I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
FWIW, your list isn't long enough -- Maori (along with most other Polynesian languages) has a dual case as well -- singular/dual/plural. The language also distinguishes between the inclusive and exclusive use of "we" -- including or excluding the person being spoken to. "We're going to the baseball game" (And you're not!) vs. "We should get together sometime." (You and I should get together.) You also overlooked the reflexive pronouns -- myself, ourselves, itself, themselves, etc. English can be a little ragged in that area, again with regard to gender. If a person of indeterminate gender should take some reflexive action does he/she do it himself? herself? itself? themself? -- Even the otherwise servicable "they" doesn't work since it is invariable plural, "themselves", when used reflexively. And interrogatives are sometimes considered pronouns -- who/whom, etc. Do even the artificial languages (Esperanto, LogLan, etc.) fill all these slots?? Paul
For completeness I should add that Maori has two categories of nouns, a-nouns and o-nouns, that take different verbal particles including pronouns. The categories are hard to keep straight for the non-native speaker (me) but seem to have something to do with portability. An interesting discussion of linguistic categories is found in George Lakoff's "Women, Fire, and Dangerous Things". The title describes one of three categories of nouns used in an Australian native language. See also: http://www.multicians.org/thvv/borges-animals.html Paul
Sep 23 2008
Paul D. Anderson wrote:BCS Wrote:I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
FWIW, your list isn't long enough -- Maori (along with most other Polynesian languages) has a dual case as well -- singular/dual/plural. The language also distinguishes between the inclusive and exclusive use of "we" -- including or excluding the person being spoken to. "We're going to the baseball game" (And you're not!) vs. "We should get together sometime." (You and I should get together.) You also overlooked the reflexive pronouns -- myself, ourselves, itself, themselves, etc. English can be a little ragged in that area, again with regard to gender. If a person of indeterminate gender should take some reflexive action does he/she do it himself? herself? itself? themself? -- Even the otherwise servicable "they" doesn't work since it is invariable plural, "themselves", when used reflexively. And interrogatives are sometimes considered pronouns -- who/whom, etc. Do even the artificial languages (Esperanto, LogLan, etc.) fill all these slots??
I can't speak for LogLan, but Esperanto is very simplified in this sense: mi (I), vi (you, both singular and plural), sxi (she), li (he), gxi (it), ni (we), ili (they). And reflexive pronouns use those same words, although you can say "mi mem" (I myself, sort of...). I sometimes miss a distinction between the signular and plural "you" in it (in English I've noticed many people say "you guys" when they want to say "not the singular you!"). So it doesn't fill all those slots, but many times you don't need to be that specific. Anyway, Esperanto is expressive in other ways... I'd also like to agree with BCS: you can learn anything in this newsgroup!Paul
Sep 23 2008
Paul D. Anderson wrote:BCS Wrote:I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
FWIW, your list isn't long enough -- Maori (along with most other Polynesian languages) has a dual case as well -- singular/dual/plural. The language also distinguishes between the inclusive and exclusive use of "we" -- including or excluding the person being spoken to. "We're going to the baseball game" (And you're not!) vs. "We should get together sometime." (You and I should get together.)
Pedant: Dual is number, not case.You also overlooked the reflexive pronouns -- myself, ourselves, itself, themselves, etc. English can be a little ragged in that area, again with regard to gender. If a person of indeterminate gender should take some reflexive action does he/she do it himself? herself? itself? themself? -- Even the otherwise servicable "they" doesn't work since it is invariable plural, "themselves", when used reflexively. And interrogatives are sometimes considered pronouns -- who/whom, etc. Do even the artificial languages (Esperanto, LogLan, etc.) fill all these slots?? Paul
And there's also case. Nominative, accusative, dative, genitive, allative, locative, and ablative are all I remember, but you could come up with a couple dozen others, I'm sure. Some languages have a fourth person, so you can unambiguously talk about two distinct groups of people who are not present. There are languages, I suspect, that cover the whole gamut, but they're going to be agglutinative, so you only need to learn a small number of parts to get the whole set.
Sep 23 2008
BCS wrote:Reply to Ary,Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
hebrew, that are all combinations of "male/female" and "singular/plural".
I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
Hum, seems I got here before Bill Baxter. :P And if you go into Japanese, you'll see even more variations. Basically Japanese has variations that depend on the tone of the speech (formal or not) Like: watashi - I (genderless and formal) atashi - I (used by females and a bit less formal) boku - I (used by males and informal) ore - I (used by males in vulgar and arrogant-sounding tone) But even freakier, sometimes, in the case of the 2nd person, they depend not on the *target* of the pronoun (the 2nd person), but also the gender of the speaker! Like: anata - you (genderless target, formal) kimi - you (genderless target, semi-formal, *used by males*) temee - you (genderless target, vulgar and insulting, *used by males*) There are probably many other variants, but I'm nowhere near an expert in Japanese. So basically you can insult someone in Japanese with just one word! So "temee" can be translated something like "You bastard!", but I always chuckle when I see anime fansubs which translate it to just the more literal "You!!!" ^^ -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Sep 23 2008
On Tue, Sep 23, 2008 at 3:25 PM, BCS <ao pathlink.com> wrote:Reply to Ary,Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
I find it most interesting that four versions of "you" exist in hebrew, that are all combinations of "male/female" and "singular/plural".
I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
You forgot inclusive vs. exclusive 3rd person plural ;) (that is, "me and other people but not you" versus "me, you, and possible other people")
Sep 23 2008
Reply to Jarrett,On Tue, Sep 23, 2008 at 3:25 PM, BCS <ao pathlink.com> wrote:Reply to Ary,Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
hebrew, that are all combinations of "male/female" and "singular/plural".
1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
and other people but not you" versus "me, you, and possible other people")
For that matter there should be 8 versions (me/not me X you/not you X Someone Else/No one Else)
Sep 23 2008
Reply to Benjamin,For that matter there should be 8 versions (me/not me X you/not you X Someone Else/No one Else)
Correction; 7 unless you count "no one at all" as a pronoun.
Sep 23 2008
BCS wrote:For that matter there should be 8 versions (me/not me X you/not you X Someone Else/No one Else)
And many languages have formal/informal versions as well (tu & vous, in french). --benji
Sep 27 2008
On Tue, Sep 23, 2008 at 4:48 PM, Jarrett Billingsley <jarrett.billingsley gmail.com> wrote:On Tue, Sep 23, 2008 at 3:25 PM, BCS <ao pathlink.com> wrote:Reply to Ary,Yigal Chripun wrote:BCS wrote:Reply to Victor,I think only stupid American feminists will tread word "he" as "discrimination". I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness. This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
everything is either male, female or (rarely) both. That included stuff like chair, table (both male), shirt (female) etc. No such problems as you describe occur in practice (in Hebrew) - either you use the male form (which is the default): "I saw someone (in the male form) steal the bag" - is understood to be someone either male or female. this is because when you say "him", someone, etc, you refer to a "person" which is a male noun. if you want to specify that it was indeed a man than just say: "I saw a _man_ ... "
I find it most interesting that four versions of "you" exist in hebrew, that are all combinations of "male/female" and "singular/plural".
I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
You forgot inclusive vs. exclusive 3rd person plural ;) (that is, "me and other people but not you" versus "me, you, and possible other people")
I of course meant *1st* person plural!
Sep 23 2008
On Tue, Sep 23, 2008 at 3:42 PM, Paul D. Anderson <paul.d.removethis.anderson comcast.andthis.net> wrote:BCS Wrote:I wonder if any language have the full tensor of pronouns? 1st/2nd/3rd person X singular/plural X male/female/mixed/neutral If you don't omit any as impossible that would be 24 words. That wold be a mouth full, including duplicates (him/her vs. he/she, we vs. us) I count 9 in English (add on me, you and them).
FWIW, your list isn't long enough -- Maori (along with most other Polynesian languages) has a dual case as well -- singular/dual/plural. The language also distinguishes between the inclusive and exclusive use of "we" -- including or excluding the person being spoken to. "We're going to the baseball game" (And you're not!) vs. "We should get together sometime." (You and I should get together.) You also overlooked the reflexive pronouns -- myself, ourselves, itself, themselves, etc. English can be a little ragged in that area, again with regard to gender. If a person of indeterminate gender should take some reflexive action does he/she do it himself? herself? itself? themself? -- Even the otherwise servicable "they" doesn't work since it is invariable plural, "themselves", when used reflexively. And interrogatives are sometimes considered pronouns -- who/whom, etc. Do even the artificial languages (Esperanto, LogLan, etc.) fill all these slots?? Paul
I need to start reading other posts before posting my own... someone already beat me to the inclusive/exclusive we, it seems :S
Sep 23 2008
On Wed, Sep 24, 2008 at 7:33 AM, Bruno Medeiros <brunodomedeiros+spam com.gmail> wrote:Hum, seems I got here before Bill Baxter. :P
:-) Hadn't even occurred to me to chime in.And if you go into Japanese, you'll see even more variations. Basically Japanese has variations that depend on the tone of the speech (formal or not) Like: watashi - I (genderless and formal) atashi - I (used by females and a bit less formal) boku - I (used by males and informal) ore - I (used by males in vulgar and arrogant-sounding tone)
"ore" is more rough, but it's not really vulgar and arrogant. Maybe "macho" is a better description for it. It's "I with testosterone". One interesting thing I noticed, just because I happen to have a young son here, is that often people will substitute "I" for "you" when talking to children. For instance people will ask my son "boku ikutsu?" literally "how old am I" instead of "how old are you?". But since they generally wouldn't call themselves "boku" and since really in Japanese you wouldn't normally need to specify the "you" or the "I" in that situation, it's clear that they really mean "you" when they say "I" in this case. But I guess that's not so different from the "royal we" in English ("Aren't we looking smart today?"). You know from context that the speaker can't possibly really mean "we", so it must mean either you or I.But even freakier, sometimes, in the case of the 2nd person, they depend not on the *target* of the pronoun (the 2nd person), but also the gender of the speaker! Like: anata - you (genderless target, formal) kimi - you (genderless target, semi-formal, *used by males*) temee - you (genderless target, vulgar and insulting, *used by males*)
temee is actually "temae" with slangy pronunciation. -ai and -ae endings get turned into -ee (pronounced like A as in "Kate") omae - is another one. used by males casually in a non-honorific context. Then you can put suffixes on some of those, like -san or -chan. For instance "omae-chan" is a sort of cutesy way to say "you" to a child. Then there's "kisama". It has the very polite -sama ending usually used for royalty and honored guests, but "kisama" is actually very insulting for some reason.There are probably many other variants, but I'm nowhere near an expert in Japanese.
Yeh, I'm no where close to actually knowing how to use all those properly. I try to stick with the safest most generic ones for fear of accidentally insulting someone.So basically you can insult someone in Japanese with just one word! So "temee" can be translated something like "You bastard!", but I always chuckle when I see anime fansubs which translate it to just the more literal "You!!!" ^^
"Temee" is pretty much exclusively for insults, but even "omae", which is used all the time in conversation, is pretty insulting if used on a superior. All these things certainly make it very hard to translate certain Japanese humor into English. --bb
Sep 23 2008
Christopher Wright wrote:And there's also case. Nominative, accusative, dative, genitive, allative, locative, and ablative are all I remember, but you could come up with a couple dozen others, I'm sure.
If you want a lot of cases, try finnish - nominative, genitive, accusative, partitive, locative (with the subdivisions inessive, elative, illative, adessive, ablative, allative), essive, exessive, translative, instructive, abessive, and comitative. In addition, they have three forms of plural. Part of me really wants to learn a language that seems that weird. Other parts of me say I already have enough to do, and I'll probably not have much use for that specific language ("Go work on learning LISP instead!") -- Simen
Sep 24 2008
On Tue, 23 Sep 2008 18:41:48 +0000 (UTC), BCS <ao pathlink.com> wrote:I think only stupid American feminists will tread word "he" as "discrimination".
I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness.
the feminist having their rights to everything having "He/She", when the masculinist would just as well assume that a woman doesn't exist on the face of the earth. What about our rights? Everyone's got a right to modify how people talk except the Men! Satanics can take the word God out of everything, Women can add the word She to everything.... Damn, if you have to add "She", why not at least put the word "SheMAle" in .... How about "He/She/SheMale" or "He/She/Trans"? Would the damn women like that?This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
I find the gender neutral part funny as well, however once in a while being able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
Sep 24 2008
Stupid hypocritical American toys used to confuse the USA and World People! By the way, in Russian language, if you say about somebody "it/that", trying to use gender-neutral form, you _will_ annoy he (or she). Because in Russian, gender-neutral form is masculine, by language rules. (Example: Petrova the doctor, Ivanova the driver, Sidorova the President... ==> doctor/driver/president are masculine nouns). If you say "it", then you mean something hermaphrodite-like, this is very bad to anybody.On Tue, 23 Sep 2008 18:41:48 +0000 (UTC), BCS <ao pathlink.com> wrote:I think only stupid American feminists will tread word "he" as "discrimination".
I'm sure that Russian girls-programmers just laugh when hear those language perversions for sexual polit-correctness.
the feminist having their rights to everything having "He/She", when the masculinist would just as well assume that a woman doesn't exist on the face of the earth. What about our rights? Everyone's got a right to modify how people talk except the Men! Satanics can take the word God out of everything, Women can add the word She to everything.... Damn, if you have to add "She", why not at least put the word "SheMAle" in .... How about "He/She/SheMale" or "He/She/Trans"? Would the damn women like that?This is correct for all Russian girls/women, which i know and spoke... Also, for persons speaking English badly (as me) it will be very difficult to use correct USA-specific PC-words. Don't be mad on this shit, i propose!
able to explicitly differentiate between gender neutral and either gender can be handy: "Officer, I saw him steal the bag,.. Er, it might have bean a woman but I'm really don't know"
Sep 25 2008
On Mon, 22 Sep 2008 19:37:06 +0100, Saaa <empty needmail.com> wrote:sie hir
ver ve vis I'm thought Ursala le Guinn had some suggestions too but I can't find them on google. see also: http://everything2.com/e2node/gender-neutral%2520pronoun http://en.wikipedia.org/wiki/Gender-neutral_pronoun But it remains the case that there is no commonly accepted solution (yet). The battle is still being fought by use (and mostly by lack of use) in the real world.
Sep 25 2008
Walter Bright wrote:http://www.reddit.com/r/programming/comments/72r6q/walter_bright_ ure_functions_in_d/
Interesting.Parameters to a pure function can be mutable, but calls cannot be
references to mutable data. Cool, this amounts the same to the "partial pure"/"contextually pure" idea Don and I discussed some time ago. Good to see you thought of the same. A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?). Will memory allocation be considered pure?Pure functions can be executed asynchronously.
own when it is worthwhile to perform such asynchronous call? Will it be okay for the compiler to create and destroy threads under the hood, without programmer intervention? -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Sep 23 2008
Bruno Medeiros wrote:Walter Bright wrote:http://www.reddit.com/r/programming/comments/72r6q/walter_bright_ ure_functions_in_d/
Interesting. >Parameters to a pure function can be mutable, but calls cannot be cached or executed asynchronously if the arguments contain any references to mutable data. Cool, this amounts the same to the "partial pure"/"contextually pure" idea Don and I discussed some time ago. Good to see you thought of the same. A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?). Will memory allocation be considered pure?
Allocating heap memory affects global state, to whit, the garbage collector's state. I can't see how you can allow memory allocation. You can call new, though, in a pure function, provided it's placement new or scope.
Sep 23 2008
Christopher Wright:Will memory allocation be considered pure?
Allocating heap memory affects global state, to whit, the garbage collector's state. I can't see how you can allow memory allocation.
The CPU isn't pure, asm changes states all the time. So even if you want to create the purest Haskell language, you have to perform impure operations at some level. This means that while your code can be pure as snow (except for I/O, done if you want using monads), the things that make it run can be impure. So it all becomes a matter of drawing a line, over that line your system/language is pure, under that line (with the microcode and transistors at the bottom) it's impure. So where's the D GC? Over or under the line? If it's considered under the line, them you may malloc memory keeping purity :-) Bye, bearophile
Sep 23 2008
"Christopher Wright" wroteBruno Medeiros wrote:Walter Bright wrote:http://www.reddit.com/r/programming/comments/72r6q/walter_bright_pure_functions_in_d/
Interesting. >Parameters to a pure function can be mutable, but calls cannot be cached or executed asynchronously if the arguments contain any references to mutable data. Cool, this amounts the same to the "partial pure"/"contextually pure" idea Don and I discussed some time ago. Good to see you thought of the same. A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?). Will memory allocation be considered pure?
Allocating heap memory affects global state, to whit, the garbage collector's state. I can't see how you can allow memory allocation. You can call new, though, in a pure function, provided it's placement new or scope.
I think memory allocation is an exception, and possibly the only exception, to the global-state rule. If you don't have memory allocation, string operations cannot be pure, you can't return classes, etc. So that limits pure to simple math stuff where you can only return structs or primary types (int, double, etc.), which IMO would be a waste of time. Not a lot of code deals with only math, most code never does. -Steve
Sep 23 2008
On Wed, Sep 24, 2008 at 10:10 AM, Christopher Wright <dhasenan gmail.com> wrote:Will memory allocation be considered pure?
Allocating heap memory affects global state, to whit, the garbage collector's state. I can't see how you can allow memory allocation.
You could potentially work out some limited form of allocation to make life easier. Just thinking out loud here, but what if you could specify that all calls in a particular pure function should alloc memory from a particular thread local pool? That would mean you could continue using conveniences like ~= type operations inside the function. You'd have to be forbidden from returning pointers into that memory, though.You can call new, though, in a pure function, provided it's placement new or scope.
And provided the constructor is pure. --bb
Sep 23 2008
Bruno Medeiros wrote:A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?).
Yes.Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.>Pure functions can be executed asynchronously. Do you realistically expect the compiler to be able to determine on its own when it is worthwhile to perform such asynchronous call? Will it be okay for the compiler to create and destroy threads under the hood, without programmer intervention?
If threads/cores get cheap enough, I think this can be done. In the meantime, pure functions make great arguments to 'futures' calls.
Sep 26 2008
Walter Bright Wrote:Bruno Medeiros wrote:Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
Pure functions allocating memory is a nice feature to have. A lot of D code wants to allocate memory. It would certainly allow more return values from pure functions. I don't know what impacts that'd have on the memory model. I've had the impression that parallelizing pure functions could be lockless.
Sep 27 2008
Jason House, el 27 de septiembre a las 07:32 me escribiste:Walter Bright Wrote:Bruno Medeiros wrote:Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
Pure functions allocating memory is a nice feature to have. A lot of D code wants to allocate memory. It would certainly allow more return values from pure functions. I don't know what impacts that'd have on the memory model. I've had the impression that parallelizing pure functions could be lockless.
But I don't see how a function can be pure if allocates, for example: pure Image rotate(Image original) { Image img = new Image(original.size) // some rotation logic return img; } If this "pure" function is called with enough memory, it will return a copy of the original image, rotated. If there is no enough memory, the function will throw (note that the input is exactly the same for both calls, but the result is different). You can add some try/catch to make it nonthrow, but if you have no memory, you can't possibly return the same image as it would be returned when memory is available. What about stack allocation? I don't even know what's the current behaviour. Can you get out of stack? Is an exception raised? The program aborted? Anything else? This is a really tricky issue indeed, because not being able to allocate in a pure function would reduce their utility greatly. -- Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/ ---------------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------------- El techo de mi cuarto lleno de cometas
Sep 27 2008
Leandro Lucarella wrote:Jason House, el 27 de septiembre a las 07:32 me escribiste:Walter Bright Wrote:Bruno Medeiros wrote:Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
Pure functions allocating memory is a nice feature to have. A lot of D code wants to allocate memory. It would certainly allow more return values from pure functions. I don't know what impacts that'd have on the memory model. I've had the impression that parallelizing pure functions could be lockless.
But I don't see how a function can be pure if allocates, for example: pure Image rotate(Image original) { Image img = new Image(original.size) // some rotation logic return img; } If this "pure" function is called with enough memory, it will return a copy of the original image, rotated. If there is no enough memory, the function will throw (note that the input is exactly the same for both calls, but the result is different). You can add some try/catch to make it nonthrow, but if you have no memory, you can't possibly return the same image as it would be returned when memory is available. What about stack allocation? I don't even know what's the current behaviour. Can you get out of stack? Is an exception raised? The program aborted? Anything else? This is a really tricky issue indeed, because not being able to allocate in a pure function would reduce their utility greatly.
You're missing the subtleties in what Walter said: "If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory." That means that if an out of memory exception occurs, the pure function (possibly even the whole program) can not catch the out of memory exception. Either a pure function will operate normally and predictably, or it has a non-recoverable error. This has to be handled differently than recoverable errors/exceptions which are predictable/repeatable.
Sep 27 2008
Reply to Jason,You're missing the subtleties in what Walter said: "If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory." That means that if an out of memory exception occurs, the pure function (possibly even the whole program) can not catch the out of memory exception. Either a pure function will operate normally and predictably, or it has a non-recoverable error. This has to be handled differently than recoverable errors/exceptions which are predictable/repeatable.
Ditto. To argue the point by taking it to the ridiculous: *Any* function can fail for any number of reasons that aren't related the to arguments; stack overflows, un-handled external signals (SIGKILL), loss of power to the the CPU, arbitrary hardware failure. The line has to be drawn somewhere, the question is only where.
Sep 28 2008
Regarding the pure function topic: is it possible to have, just at debug time, the possibility to add special debugging printing statements into pure functions? :-) Maybe now I am asking something silly... because the order of their prints and the number of times such function is called isn't defined by the compiler, and it may even change. Another possible way to debug is for the programmer to temporary remove the "pure" statement(s), add some debugging writefln/putr/stdios, compile, run, see the output, put the "pure"(s) back, etc, etc... :-) Bye, bearophile
Sep 29 2008
Sorry, I have forgotten to add a small thing. In Haskell they have solved the debugging problem in some ways, like this: http://cvs.haskell.org/Hugs/pages/libraries/base/Debug-Trace.html But that solution may require installing the concept of monads into the brain of most D programmers first :-) Bye, bearophile
Sep 29 2008
bearophile a écrit :Sorry, I have forgotten to add a small thing. In Haskell they have solved the debugging problem in some ways, like this: http://cvs.haskell.org/Hugs/pages/libraries/base/Debug-Trace.html But that solution may require installing the concept of monads into the brain of most D programmers first :-)
Sure, D should have monads as soon as Haskell programmers are able to explain this concept to 'normal' programmers (and no cheating such as the classical handwaving, this is a way to wrap side effects..) So probably never then. That said, I agree very much that allowing debug output and memory allocation in pure function makes them much more useful while keeping their 'purity'. So I vote +1 Bye, renoXBye, bearophile
Oct 02 2008
renoX:Sure, D should have monads as soon as Haskell programmers are able to explain this concept to 'normal' programmers (and no cheating such as the classical handwaving, this is a way to wrap side effects..) So probably never then.
You can try reading this: http://en.wikipedia.org/wiki/Monad_(functional_programming) If D wants to add some functional-style features to itself, then I think D programmers have to learn some functional-style idioms and style, otherwise those changes/additions D become useless. Do you agree? On the other hand I presume many D programmers know some functional programming, from Haskell, Scheme, or even Python... Bye, bearophile
Oct 02 2008
renoX:Sure, D should have monads as soon as Haskell programmers are able to explain this concept to 'normal' programmers (and no cheating such as the classical handwaving, this is a way to wrap side effects..) So probably never then.
You can also read this, it's quite easy: http://www.reddit.com/r/programming/comments/64th1/monads_in_python_in_production_code_you_can_and/c02u9mb It also shows how they have already solved the problem of exceptions in languages with pure functions, with the Maybe monad :-) As I've said in the past, functional programming doesn't work alone, it works in an ecology of features. So adding a single thing isn't enough. For example you may need a compiler able of tail call elimination (GCC is able to do this sometimes), have a short lambda syntax (like the C# one: x => x*2 ), have more type inferencing (a stronger type system), closures, simple ways to manage immutability, pure functions, plus other smaller things. Among the smaller things I'd like there's a generic len() function similar to the Python one and the one I've put in my libs. It's able to call the length attribute if present, and to count items in a lazy iterable too. You can use it this way: auto b = sorted(a, &len!(BaseType1!(typeof(a)))); That works, and sorts the items of the a iterable according to the length of its items. BaseType1 is a template that returns the type of the items at the first level that the given type contains/yields. That shows the type system isn't strong enough yet for higher order functional programming, because len is a function template, and you have to specialize it manually to find its pointer/delegate. In a language with a more powerful type system you may use: auto b = sorted(a, len) Bye, bearophile
Oct 02 2008
On 2008-10-03 01:37:40 +0200, bearophile <bearophileHUGS lycos.com> said:renoX:Sure, D should have monads as soon as Haskell programmers are able to explain this concept to 'normal' programmers (and no cheating such as the classical handwaving, this is a way to wrap side effects..) So probably never then.
You can also read this, it's quite easy: http://www.reddit.com/r/programming/comments/64th1/monads_in_python_in_production_code_you_can_and/c02u9mb
Italso shows how they have already solved the problem of exceptions in languages with pure functions, with the Maybe monad :-) As I've said in the past, functional programming doesn't work alone, it works in an ecology of features. So adding a single thing isn't enough. For example you may need a compiler able of tail call elimination (GCC is able to do this sometimes), have a short lambda syntax (like the C# one: x => x*2 ), have more type inferencing (a stronger type system), closures, simple ways to manage immutability, pure functions, plus other smaller things. Among the smaller things I'd like there's a generic len() function similar to the Python one and the one I've put in my libs. It's able to call the length attribute if present, and to count items in a lazy iterable too. You can use it this way: auto b = sorted(a, &len!(BaseType1!(typeof(a)))); That works, and sorts the items of the a iterable according to the length of its items. BaseType1 is a template that returns the type of the items at the first level that the given type contains/yields. That shows the type system isn't strong enough yet for higher order functional programming, because len is a function template, and you have to specialize it manually to find its pointer/delegate. In a language with a more powerful type system you may use: auto b = sorted(a, len) Bye, bearophile
Functional programming doesn't necessarily need a stronger type system, it might also have a weaker one, don't forget lisp & co, you just move things to the runtime... Fawzi
Oct 03 2008
bearophile a écrit :renoX:Sure, D should have monads as soon as Haskell programmers are able to explain this concept to 'normal' programmers (and no cheating such as the classical handwaving, this is a way to wrap side effects..) So probably never then.
You can try reading this: http://en.wikipedia.org/wiki/Monad_(functional_programming)
Sorry, but this is still above my level of understanding, and I've been programming for quite a long time (and have been curious of many things in programming)..If D wants to add some functional-style features to itself, then I think D programmers have to learn some functional-style idioms and style, otherwise those changes/additions D become useless. Do you agree?
In general yes, in this case no: AFAIK, monads are only useful for "pure" functional language which D isn't and won't ever be. IMHO, functional programming has some good stuff which are easy to use and understand that D should steal such as "pure functions" but monads aren't such thing: they're very hard to understand, so their correct usage isn't obvious and in an impure language I fail to see their interest.. Regards, Renaud.On the other hand I presume many D programmers know some functional programming, from Haskell, Scheme, or even Python... Bye, bearophile
Oct 08 2008
renoX:Sorry, but this is still above my level of understanding, and I've been programming for quite a long time (and have been curious of many things in programming)..
Around the net there are many tutorials on them, this is very simple: http://www.reddit.com/r/programming/comments/64th1/monads_in_python_in_production_code_you_can_and/c02u9mb To understand them I think you can: - I think you have to "unlearn" some of the things you know; - read explanations about them - to install Haskell and start learning it, with time you will learn.In general yes, in this case no: AFAIK, monads are only useful for "pure" functional language which D isn't and won't ever be.
If you say you don't undestand monads, how can you tell they can't be useful for the future D? As far as we today know, monads allow you to use pure functions in the most effective way. For example using monads is the best known way to solve the logging and the exception problems of pure fuctions. So I think they can be useful for the future D too.IMHO, functional programming has some good stuff which are easy to use and understand that D should steal such as "pure functions" but monads aren't such thing: they're very hard to understand, so their correct usage isn't obvious and in an impure language I fail to see their interest..
They aren't so hard to understand. In C++ there are several concepts that are as much or more difficult to understand. Bye, bearophile
Oct 08 2008
bearophile a écrit :renoX:Sorry, but this is still above my level of understanding, and I've been programming for quite a long time (and have been curious of many things in programming)..
Around the net there are many tutorials on them, this is very simple: http://www.reddit.com/r/programming/comments/64th1/monads_in_python_in_production_code_you_can_and/c02u9mb
I've read it too, without success also.To understand them I think you can: - I think you have to "unlearn" some of the things you know; - read explanations about them - to install Haskell and start learning it, with time you will learn.
No, I'm not interested in Haskell, as long as I can't learn monads I'm not interested plus there's D, Scala, F#, Ruby, etc, already lots of interesting language to learn..In general yes, in this case no: AFAIK, monads are only useful for "pure" functional language which D isn't and won't ever be.
If you say you don't undestand monads, how can you tell they can't be useful for the future D? As far as we today know, monads allow you to use pure functions in the most effective way. For example using monads is the best known way to solve the logging and the exception problems of pure fuctions.
First I'm not convinced that pure functions have an issue with exceptions, second if you can cast an output function as a pure function (lying to the compiler in some way) then the logging issue is solved: this is something that I can understand easily, no need for weird monads.So I think they can be useful for the future D too.IMHO, functional programming has some good stuff which are easy to use and understand that D should steal such as "pure functions" but monads aren't such thing: they're very hard to understand, so their correct usage isn't obvious and in an impure language I fail to see their interest..
They aren't so hard to understand. In C++ there are several concepts that are as much or more difficult to understand.
C++ isn't simple I agree, but usually the things really hard to understand are weird corner case, that one can mostly ignore but monads are a fundamental concepts for Haskell (otherwise no IO). renoXBye, bearophile
Oct 09 2008
renoX:No, I'm not interested in Haskell, as long as I can't learn monads I'm not interested<
My idea is that you can start learning Haskell, doing practice, learning how you do I/O, etc, even if you don't know what they are. You use monads everywhere from the beginning, but to do basic I/O you don't need to understand them. With time your mind starts to generalize what they are and what they can do. It may take several months, but it's fun :-)plus there's D, Scala, F#, Ruby, etc, already lots of interesting language to learn..<
Note that monads are used in F# too, and I presume in few months/years we'll see them in Scala too ;-) And currently Haskell is one of the most interesting languages to learn, even more interesting than Prolog :-) Bye, bearophile
Oct 09 2008
bearophile a écrit :renoX:No, I'm not interested in Haskell, as long as I can't learn monads I'm not interested<
My idea is that you can start learning Haskell, doing practice, learning how you do I/O, etc, even if you don't know what they are.
I don't like magic, perhaps it's because I learned assembly language too early but I had the same issue with OO languages: until I managed to understand how inheritance worked, it was always bugging me.. Unfortunately monads are *way harder* to understand than inheritance! [cut]Note that monads are used in F# too, and I presume in few months/years we'll see them in Scala too ;-)
F# being impure, I wonder if monads are used often in F#?And currently Haskell is one of the most interesting languages to learn, even more interesting than Prolog :-)
YMMV: Learned Prolog and Lisp at school, never used those and didn't get any interest in using them from the school lessons, and I feel the same about Haskell: a language for researchers, nice for melting your brain sure, but not something I'm interested in: functional language are not my thing. D's users being practical guys, I doubt that I'm alone in my desinterest in Haskell. renoX
Oct 10 2008
bearophile escribió:Regarding the pure function topic: is it possible to have, just at debug time, the possibility to add special debugging printing statements into pure functions? :-) Maybe now I am asking something silly... because the order of their prints and the number of times such function is called isn't defined by the compiler, and it may even change. Another possible way to debug is for the programmer to temporary remove the "pure" statement(s), add some debugging writefln/putr/stdios, compile, run, see the output, put the "pure"(s) back, etc, etc... :-)
Can't a debugger enter pure functions?Bye, bearophile
Sep 29 2008
Mon, 29 Sep 2008 18:38:19 -0300, bearophile escribio:Regarding the pure function topic: is it possible to have, just at debug time, the possibility to add special debugging printing statements into pure functions? :-)
I think you can pretend that a debug trace is pure if it can't fail and is internally synchronized. Also see below. Ary Borenszweig wrote:Can't a debugger enter pure functions?
Can a debugger enter a new thread? I think not unless you've set a breakpoint there. Though I think in debug mode (no -O option) pure functions should be executed sequentially and in a single thread so that they can be traditionally debugged. This also solves the out-of-order tracing problem.
Sep 29 2008
== Quote from bearophile (bearophileHUGS lycos.com)'s articleRegarding the pure function topic: is it possible to have, just at debug time, the possibility to add special
Maybe now I am asking something silly... because the order of their prints and the number of times such
Another possible way to debug is for the programmer to temporary remove the "pure" statement(s), add
Monads ;-) Otherwise, something like this should work: void debugln_(...) { /* forward to writefln */ } alias pure void function(...) SomeFn; SomeFn debugln = cast(pure SomeFn) &debugln_; Sean
Sep 29 2008
Sean Kelly:Otherwise, something like this should work: void debugln_(...) { /* forward to writefln */ } alias pure void function(...) SomeFn; SomeFn debugln = cast(pure SomeFn) &debugln_;
I think you have written a static cast from the function pointer of an impure function to a function pointer of a pure function. I kind of hope the compiler will forbid a cast like that, I think it may give troubles :-) This topic makes me more and more amused as time passes :-) Bye, bearophile
Sep 29 2008
== Quote from bearophile (bearophileHUGS lycos.com)'s articleSean Kelly:Otherwise, something like this should work: void debugln_(...) { /* forward to writefln */ } alias pure void function(...) SomeFn; SomeFn debugln = cast(pure SomeFn) &debugln_;
troubles :-) The compiler allows one to add "invariant" with a cast, so why not "pure?" Casting is basically a sledgehammer emblazoned with the label "trust me, I know what I'm doing." Sean
Sep 29 2008
Reply to bearophile,Sean Kelly:Otherwise, something like this should work: void debugln_(...) { /* forward to writefln */ } alias pure void function(...) SomeFn; SomeFn debugln = cast(pure SomeFn) &debugln_;
impure function to a function pointer of a pure function. I kind of hope the compiler will forbid a cast like that, I think it may give troubles :-) This topic makes me more and more amused as time passes :-) Bye, bearophile
To forbid such a cast, you would need to forbid pointers to pure functions. You can subvert the type system with unions if nothing else and for something like pure, there is no point in limiting casts if there are ways around it. union Cast (R, T...) { R function(T) nonPure; pure R function(T) pure; }
Sep 29 2008
BCS:To forbid such a cast, you would need to forbid pointers to pure functions. You can subvert the type system with unions if nothing else and for something like pure, there is no point in limiting casts if there are ways around it.
If it turns out that casting impure => pure is very dangerous (and I don't know yet how much dangerous it can be), then it may be useful anyway to forbid the simple impure => pure cast, forcing the programmers to perform that cast with a union. So it becomes a way to tell the programmer that operation is very discouraged :-) Bye, bearophile
Sep 29 2008
Reply to bearophile,BCS:To forbid such a cast, you would need to forbid pointers to pure functions. You can subvert the type system with unions if nothing else and for something like pure, there is no point in limiting casts if there are ways around it.
don't know yet how much dangerous it can be), then it may be useful anyway to forbid the simple impure => pure cast, forcing the programmers to perform that cast with a union. So it becomes a way to tell the programmer that operation is very discouraged :-) Bye, bearophile
If the correct way is to use a cast, you can grep for it, if you need to use a union, it will be extremely hard to find such casts. Thus the reason to allow the cast or make it totally impossible.
Sep 29 2008
On 2008-09-27 02:07:59 -0400, Walter Bright <newshound1 digitalmars.com> said:Bruno Medeiros wrote:A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?).
Yes.Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
Or you could go in between: allow memory allocation exceptions to be caught, but only when not in a pure function. This way pure functions still always give the same result, or fail and allow non-pure code to handle gracefully the situation (displaying an error message for instance). Making pure functions completely non-recoverable would mean that in a GUI app, for instance, every time you'd call a pure function allocating some memory you'd run the risk of terminating the app, which is not really acceptable. And I think memory allocation is a must, given that without it you can't create, or append to, arrays or strings, and you make pure functions limited to working with pre-existing buffers (which would be then passed by reference, preventing hoisting). -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Sep 27 2008
== Quote from Michel Fortin (michel.fortin michelf.com)'s articleOn 2008-09-27 02:07:59 -0400, Walter Bright <newshound1 digitalmars.com> said:Bruno Medeiros wrote:A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?).
Yes.Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
caught, but only when not in a pure function. This way pure functions still always give the same result, or fail and allow non-pure code to handle gracefully the situation (displaying an error message for instance). Making pure functions completely non-recoverable would mean that in a GUI app, for instance, every time you'd call a pure function allocating some memory you'd run the risk of terminating the app, which is not really acceptable. And I think memory allocation is a must, given that without it you can't create, or append to, arrays or strings, and you make pure functions limited to working with pre-existing buffers (which would be then passed by reference, preventing hoisting).
What about stack overflows, etc.? Calling a pure function can also bring down your app if you're out of stack space. I think it's important to remember that any notion of functional purity exists at the level of the language abstraction, not at the bare metal level. Therefore, anything that breaks the language abstraction is going to break any concept of functional purity. Heck, given the proper hardware or compiler bugs, even functions that are pure by the strictest definitions can have side effects.
Sep 27 2008
Sun, 28 Sep 2008 07:28:19 +0900, Bill Baxter wrote:But I think a stack overflow is something that doesn't usually occur in a properly written program, and they are also are not something you can recover from. Insufficient memory errors can be and often are recovered from. E.g. you try to create a giant image in an image editing program, if there's not enough memory your image editor *should* realize the image alloc failed and bail out gracefully telling you there's not enough memory for that operation.
My thoughts so far. Since a real purity is unachievable, there are different grades of purity which make a practical difference: A. Independence of an external state in the sense that a pure function can be executed in parallel without the need for synchronization. This is the simplest, most obvious and a must have kind of purity. It also allows for an arbitrary execution order of functions with independent arguments and results. Even malloc() conforms to this kind of purity because memory management is thread-safe at the low level anyway so it can be executed in parallel without compiler taking additional precautions. B. Repeatability of the result that allows to cache parameters and reuse the same result if the same parameters are given. This type of purity is way stricter than the first and is harder to check and utilize. What happens if an exception is thrown? Purity of type A is perfectly preserved. Naturally, an exception can happily be thrown in parallel and in any order. Purity of type B can also be preserved if an exception is thrown consistently with function parameters and compiler is able to prove that. If another kind of exception is thrown, the purity B is broken. What does it mean, broken purity? It means that any results of a B-pure computation are invalid and must be discarded. I think that a smart compiler should catch exceptions from B-pure functions and, if an exception is unexpected, wrap them in a PurityError exception which B- pure functions must never catch. Yet this exception does no harm to the purity of A-pure functions and can be handled there. Now to exception handling. Any exceptions from A-pure functions and selected exceptions from B-pure functions are considered the function result. Therefore try { localState = pureFun(); } catch(...) { localState = ... } is a valid pure statement, it can be executed in parallel and in any order with the surrounding statements and localState can be completely replaced with a cached or pre-computed value if pureFunc is B-pure. This is actually valid for any try-catch statement with an important note: the statements inside the try block can never be executed in parallel to each other, though B-pure functions still can be replaced with their cached values/exceptions. Also a try-catch block in a B-pure function can never catch a PurityError. The image creation routine in your example is A-pure because it creates new image every time it is called with the same arguments. It can safely throw OutOfMemory which you catch and report to the user via something completely unpure.
Sep 27 2008
Walter Bright:Bruno Medeiros:Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
Walter, I think you may ask that question here: http://lambda-the-ultimate.org/ If the questions are asked honestly (and you explain that it is a quite important question, because it may determine part of the functional future of D), they are generally happy to answer all they know. Bye, bearophile
Sep 27 2008
Walter Bright wrote:Bruno Medeiros wrote:Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
Another option is for pure functions to use a blocking, never-fail allocator. That is, when a pure function allocates and we don't have enough memory, then instead of returning an out-of-memory exception, that thread will block until memory is freed. Of course, that would mean deadlock if we only had one thread, or if all threads blocked in this same situation, so we might want to have "kill the application" code to handle that case.
Sep 29 2008
Walter Bright wrote:Bruno Medeiros wrote:>Pure functions can be executed asynchronously. Do you realistically expect the compiler to be able to determine on its own when it is worthwhile to perform such asynchronous call? Will it be okay for the compiler to create and destroy threads under the hood, without programmer intervention?
If threads/cores get cheap enough, I think this can be done. In the meantime, pure functions make great arguments to 'futures' calls.
What if a function is pure but memory expensive? Say we are in loop, and the compiler spawns, say, 8 threads to run that function asynchronously... that could increase the program's memory consumption 8 fold, all under the hood. -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Oct 03 2008
On Sun, Sep 28, 2008 at 7:12 AM, dsimcha <dsimcha yahoo.com> wrote:== Quote from Michel Fortin (michel.fortin michelf.com)'s articleOn 2008-09-27 02:07:59 -0400, Walter Bright <newshound1 digitalmars.com> said:Bruno Medeiros wrote:A few questions: If a pure function can throw, is it required that it always throws given the same inputs (and throwing the same Exception?).
Yes.Will memory allocation be considered pure?
I don't know yet. If memory allocation failure is a non-recoverable exception, then pure functions can allocate memory.
caught, but only when not in a pure function. This way pure functions still always give the same result, or fail and allow non-pure code to handle gracefully the situation (displaying an error message for instance). Making pure functions completely non-recoverable would mean that in a GUI app, for instance, every time you'd call a pure function allocating some memory you'd run the risk of terminating the app, which is not really acceptable. And I think memory allocation is a must, given that without it you can't create, or append to, arrays or strings, and you make pure functions limited to working with pre-existing buffers (which would be then passed by reference, preventing hoisting).
What about stack overflows, etc.? Calling a pure function can also bring down your app if you're out of stack space. I think it's important to remember that any notion of functional purity exists at the level of the language abstraction, not at the bare metal level. Therefore, anything that breaks the language abstraction is going to break any concept of functional purity. Heck, given the proper hardware or compiler bugs, even functions that are pure by the strictest definitions can have side effects.
But I think a stack overflow is something that doesn't usually occur in a properly written program, and they are also are not something you can recover from. Insufficient memory errors can be and often are recovered from. E.g. you try to create a giant image in an image editing program, if there's not enough memory your image editor *should* realize the image alloc failed and bail out gracefully telling you there's not enough memory for that operation. --bb
Sep 27 2008









Jason House <jason.james.house gmail.com> 