public inbox for [email protected]  
help / color / mirror / Atom feed
Nit: "Immutable" should be "pure"
4+ messages / 4 participants
[nested] [flat]

* Nit: "Immutable" should be "pure"
@ 2019-11-07 14:17 PG Doc comments form <[email protected]>
  2019-11-07 17:28 ` Re: Nit: "Immutable" should be "pure" Bruce Momjian <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Doc comments form @ 2019-11-07 14:17 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/sql-createindex.html
Description:

The adjective "immutable" describing the functions and operators used in an
index (see two occurrences in doc snippet below) is incorrect and should be
replaced with "pure". Both "pure" and "immutable" are in popular lexicon now
because of the interest in functional programming, so conflating the two can
happen, but the word immutable applies to data and pure applies to
functions. See https://en.wikipedia.org/wiki/Pure_function. 

From the CREATE INDEX doc:
All functions and operators used in an index definition must be “immutable”,
that is, their results must depend only on their arguments and never on any
outside influence (such as the contents of another table or the current
time). This restriction ensures that the behavior of the index is
well-defined. To use a user-defined function in an index expression or WHERE
clause, remember to mark the function immutable when you create it.


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Nit: "Immutable" should be "pure"
  2019-11-07 14:17 Nit: "Immutable" should be "pure" PG Doc comments form <[email protected]>
@ 2019-11-07 17:28 ` Bruce Momjian <[email protected]>
  2019-11-07 17:38   ` Re: Nit: "Immutable" should be "pure" Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Bruce Momjian @ 2019-11-07 17:28 UTC (permalink / raw)
  To: [email protected]; [email protected]

On Thu, Nov  7, 2019 at 02:17:58PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/12/sql-createindex.html
> Description:
> 
> The adjective "immutable" describing the functions and operators used in an
> index (see two occurrences in doc snippet below) is incorrect and should be
> replaced with "pure". Both "pure" and "immutable" are in popular lexicon now
> because of the interest in functional programming, so conflating the two can
> happen, but the word immutable applies to data and pure applies to
> functions. See https://en.wikipedia.org/wiki/Pure_function. 
> 
> From the CREATE INDEX doc:
> All functions and operators used in an index definition must be “immutable”,
> that is, their results must depend only on their arguments and never on any
> outside influence (such as the contents of another table or the current
> time). This restriction ensures that the behavior of the index is
> well-defined. To use a user-defined function in an index expression or WHERE
> clause, remember to mark the function immutable when you create it.

Well, we use IMMUTABLE as an option to CREATE FUNCTION so I don't see
how we can realign to the new word meanings without a lot of confusion:

       CREATE [ OR REPLACE ] FUNCTION
           name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] )
           [ RETURNS rettype
             | RETURNS TABLE ( column_name column_type [, ...] ) ]
         { LANGUAGE lang_name
           | TRANSFORM { FOR TYPE type_name } [, ... ]
           | WINDOW
           | IMMUTABLE | STABLE | VOLATILE | [ NOT ] LEAKPROOF
             ^^^^^^^^^

I think the best we can do is to mention that IMMUTABLE functions mean
pure, but I am not sure there is even enough demand for that, vs.
confusing people.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Nit: "Immutable" should be "pure"
  2019-11-07 14:17 Nit: "Immutable" should be "pure" PG Doc comments form <[email protected]>
  2019-11-07 17:28 ` Re: Nit: "Immutable" should be "pure" Bruce Momjian <[email protected]>
@ 2019-11-07 17:38   ` Tom Lane <[email protected]>
  2019-11-07 18:04     ` Re: Nit: "Immutable" should be "pure" Brian Williams <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2019-11-07 17:38 UTC (permalink / raw)
  To: Bruce Momjian <[email protected]>; +Cc: [email protected]; [email protected]

Bruce Momjian <[email protected]> writes:
> On Thu, Nov  7, 2019 at 02:17:58PM +0000, PG Doc comments form wrote:
>> The adjective "immutable" describing the functions and operators used in an
>> index (see two occurrences in doc snippet below) is incorrect and should be
>> replaced with "pure".

> I think the best we can do is to mention that IMMUTABLE functions mean
> pure, but I am not sure there is even enough demand for that, vs.
> confusing people.

Yeah.  I don't think this terminology is nearly as universal
as the OP believes, so I don't feel a need to change anything.

If we adopt Corey's proposal to create a glossary [1], there'd be
room for a parenthetical comment like "(In some circles, "pure" is the
preferred term for this function property.)" in the glossary entry for
"immutable".  I suspect it won't be the only entry that needs
cross-references to other terminology.

			regards, tom lane

[1] https://commitfest.postgresql.org/25/2305/





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Nit: "Immutable" should be "pure"
  2019-11-07 14:17 Nit: "Immutable" should be "pure" PG Doc comments form <[email protected]>
  2019-11-07 17:28 ` Re: Nit: "Immutable" should be "pure" Bruce Momjian <[email protected]>
  2019-11-07 17:38   ` Re: Nit: "Immutable" should be "pure" Tom Lane <[email protected]>
@ 2019-11-07 18:04     ` Brian Williams <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Brian Williams @ 2019-11-07 18:04 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Bruce Momjian <[email protected]>; [email protected]

Thanks for the feedback folks. I had not seen the IMMUTABLE argument to CREATE FUNCTION and realize this change is too expensive.

This probably will not be the last you hear on this since pureness and immutability are all the rage in development circles.   

> On Nov 7, 2019, at 12:38 PM, Tom Lane <[email protected]> wrote:
> 
> Bruce Momjian <[email protected]> writes:
>> On Thu, Nov  7, 2019 at 02:17:58PM +0000, PG Doc comments form wrote:
>>> The adjective "immutable" describing the functions and operators used in an
>>> index (see two occurrences in doc snippet below) is incorrect and should be
>>> replaced with "pure".
> 
>> I think the best we can do is to mention that IMMUTABLE functions mean
>> pure, but I am not sure there is even enough demand for that, vs.
>> confusing people.
> 
> Yeah.  I don't think this terminology is nearly as universal
> as the OP believes, so I don't feel a need to change anything.
> 
> If we adopt Corey's proposal to create a glossary [1], there'd be
> room for a parenthetical comment like "(In some circles, "pure" is the
> preferred term for this function property.)" in the glossary entry for
> "immutable".  I suspect it won't be the only entry that needs
> cross-references to other terminology.
> 
> 			regards, tom lane
> 
> [1] https://commitfest.postgresql.org/25/2305/







^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-11-07 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07 14:17 Nit: "Immutable" should be "pure" PG Doc comments form <[email protected]>
2019-11-07 17:28 ` Bruce Momjian <[email protected]>
2019-11-07 17:38   ` Tom Lane <[email protected]>
2019-11-07 18:04     ` Brian Williams <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox