Re: Facade Functional Programming Suite
Posted: 21 Jul 2019, 11:18
I updated Facade’s Op library today. It is one of the oldest libraries and had not received much attention for a long time.
It became more Lisp-like and less like Python’s operator library, both of which have been inspirations.
Op_Pow was renamed Op_Expt.
Op_Neg was removed. Use Op_Sub with 1 argument instead.
Op_Mul, Op_Div, Op_Add, Op_Sub, Op_BitAnd, Op_BitXor, Op_BitOr, and the relational functions became variadic.
The String library’s case-insensitive relational functions also became variadic.
This should further reduce verbosity. The documentation mentions potentially non-obvious uses for these features.
I noticed AutoHotkey’s floor division operator is broken and corrected Op_FloorDiv accordingly (along with several internal uses ). It now always performs floor division and always returns an integer, which is what you want in practice.
I removed Op_Rem because it does not appear to be useful when you have Op_Mod. Floor division and modulo, both based on floor division, have a relationship similar to that of quotient and remainder, both based on truncation. Floor division and modulo are more useful in practice.
I also renamed some other things in an attempt to make the libraries more consistent and easier to understand.
Op_GetAttr was renamed Op_GetProp because AutoHotkey seems to prefer the term property to attribute.
Op_GetItem was renamed back to Op_Get.
The names getattr and getitem were taken from Python, where there are related setattr (for the outside) and setitem (for the inside) methods. This flailing is the result of me trying to find the best way to cope with AutoHotkey conflating arrays and dictionaries, conflating objects’ outside with their insides, and using 1-based indexing. Op_GetProp just tries to read what might be an attribute (i.e. it reads the outside). To be clear, it will not try to use a Get(Key) method to read what it was told. Op_Get tries to use a Get(Key) method to read what it was told if the object is of a type other than Object (i.e. it reads the inside). It will read AutoHotkey's property-key abomination if a Get(Key) method does not exist. The difference can matter if you have an AutoHotkey object with both properties and a Get(Key) method. Array_Get performs index adjustment when reading from Objects so that you can pretend you are using 0-based indexing when you need to calculate an index. Op_Get does not because integers are perfectly reasonable keys and you would not want index adjustment unless you were using an Object as an Array.
The Cons functions were renamed to Prepend functions. This makes them less Lisp-like but hopefully more understandable, like using first and rest instead of car and cdr. I am pretty sure nobody outside the Lisp community wants me to reintroduce that cdadar stuff.
I included a demonstration of using Facade to solve constraint programming problems in the documentation about a week ago and forgot to mention it here. It shows how to solve the 8 Queens problem using Facade’s Streams.
It became more Lisp-like and less like Python’s operator library, both of which have been inspirations.
Op_Pow was renamed Op_Expt.
Op_Neg was removed. Use Op_Sub with 1 argument instead.
Op_Mul, Op_Div, Op_Add, Op_Sub, Op_BitAnd, Op_BitXor, Op_BitOr, and the relational functions became variadic.
The String library’s case-insensitive relational functions also became variadic.
This should further reduce verbosity. The documentation mentions potentially non-obvious uses for these features.
I noticed AutoHotkey’s floor division operator is broken and corrected Op_FloorDiv accordingly (along with several internal uses ). It now always performs floor division and always returns an integer, which is what you want in practice.
I removed Op_Rem because it does not appear to be useful when you have Op_Mod. Floor division and modulo, both based on floor division, have a relationship similar to that of quotient and remainder, both based on truncation. Floor division and modulo are more useful in practice.
I also renamed some other things in an attempt to make the libraries more consistent and easier to understand.
Op_GetAttr was renamed Op_GetProp because AutoHotkey seems to prefer the term property to attribute.
Op_GetItem was renamed back to Op_Get.
The names getattr and getitem were taken from Python, where there are related setattr (for the outside) and setitem (for the inside) methods. This flailing is the result of me trying to find the best way to cope with AutoHotkey conflating arrays and dictionaries, conflating objects’ outside with their insides, and using 1-based indexing. Op_GetProp just tries to read what might be an attribute (i.e. it reads the outside). To be clear, it will not try to use a Get(Key) method to read what it was told. Op_Get tries to use a Get(Key) method to read what it was told if the object is of a type other than Object (i.e. it reads the inside). It will read AutoHotkey's property-key abomination if a Get(Key) method does not exist. The difference can matter if you have an AutoHotkey object with both properties and a Get(Key) method. Array_Get performs index adjustment when reading from Objects so that you can pretend you are using 0-based indexing when you need to calculate an index. Op_Get does not because integers are perfectly reasonable keys and you would not want index adjustment unless you were using an Object as an Array.
The Cons functions were renamed to Prepend functions. This makes them less Lisp-like but hopefully more understandable, like using first and rest instead of car and cdr. I am pretty sure nobody outside the Lisp community wants me to reintroduce that cdadar stuff.
I included a demonstration of using Facade to solve constraint programming problems in the documentation about a week ago and forgot to mention it here. It shows how to solve the 8 Queens problem using Facade’s Streams.