Exotic Logics
Lie Ryan
lie.1296 at gmail.com
Wed Jun 17 17:21:27 EDT 2009
pdpi wrote:
> On Jun 17, 5:37 pm, Lie Ryan <lie.1... at gmail.com> wrote:
>> Steven D'Aprano wrote:
>>> On Tue, 16 Jun 2009 22:46:14 -0700, William Clifford wrote:
>>>> I was staring at a logic table the other day, and I asked myself, "what
>>>> if one wanted to play with exotic logics; how might one do it?"
>>> This might be useful for you, and if not useful, at least it might blow
>>> your mind like it did mine.
>>> (This is not original to me -- I didn't create it. However, I can't find
>>> the original source.)
>>> Imagine for a moment that there are no boolean values.
>>> There are no numbers. They were never invented.
>>> There are no classes.
>>> There are no objects.
>>> There are only functions.
>>> Could you define functions that act like boolean values? And could you
>>> define other functions to operate on them?
>>> def true(x, y):
>>> return x
>>> def false(x, y):
>>> return y
>>> def print_bool(b):
>>> print b("true", "false")
>> String isn't considered object?
>>
>> Also, b/true()/false() is a function object, isn't it? Unless function
>> is first-class, you can't pass them around like that, since you need a
>> function pointer (a.k.a number); but if function is first-class then
>> there it is an object.
>
> What Steven was doing was implementing some of the more basic stuff
> from Lambda calculus in python. If you're implementing a different
> system in an existing language, you'll need to use _some_ facilities
> of the original language to interface with the outside world. Anyway,
> here's a sample interactive session I just tried:
>
>>>> def a(stuff):
> .... print stuff
> ....
>>>> def b(stuff):
> .... stuff("abc")
> ....
>>>> b(a)
> abc
>
> functions are first-class citizens in python.
I've just reread my sentence, and even I wouldn't have understood (or
would misunderstood) what I was talking about if it was worded like that.
What I meant was: if you can pass a function as an argument to another
function, that means either: 1) you must use function pointer (numbers)
or 2) function is a first-class object. Both violates the restriction
(no number and no object respectively).
Even after abandoning the semantics of functions in python, going to
function as in purely mathematical sense, I still am not convinced
(warning: I don't know lambda calculus, although I program in heavily
functional style).
PS: the string comment was meant to be a joke...
More information about the Python-list
mailing list