Skip to content

Instantly share code, notes, and snippets.

@mobeets
Last active December 31, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mobeets/8063671 to your computer and use it in GitHub Desktop.
Save mobeets/8063671 to your computer and use it in GitHub Desktop.
figurative language meets programming
// in C you can express metaphors, e.g. "Noon's house is a bear":
#include "stdio.h"
typedef struct {
char *street;
int street_number;
} noons_house_t;
typedef struct {
int hungriness;
} bear_t;
int main() {
noons_house_t noons_house;
noons_house.street_number = 7;
noons_house.street = "wherever Noon lives";
bear_t *bear = (bear_t*)(&noons_house);
printf("Noon's house is a bear of hungriness %d\n", bear->hungriness);
return 0;
}
// reuben@mint-vm ~/projects/metaphor $ gcc metaphor.c
// reuben@mint-vm ~/projects/metaphor $ ./a.out
// Noon's house is a bear of hungriness 4195888
def simile(a):
"""
e.g. "a is like float(a)"
"""
assert type(a) is int
A = float(1)
assert A == a and type(A) != type(a) # semantically the same
assert A is not a # but not literally the same
def metaphor(a):
"""
e.g. "a is float(a)"
"""
assert type(a) is int
A = float(a)
assert A is a
def paradox(a):
assert a is not a
def hyperbole(a):
"""
e.g. "a is soooooo big, it's bigger than the biggest int"
"""
assert type(a) is int
import sys
A = sys.maxint + 1.0
assert a > A
def metonymy(a, attribute):
"""
e.g. referring to one of a's attributes as if it were equivalent to a
itself
"""
assert hasattr(a, attribute)
A = getattr(a, attribute)
assert A == a
assert A is a
assert type(A) is type(a)
def personification(a):
"""
e.g. "a's eyes are like the setting sun"
but a has no eyes()
"""
class Person:
def eyes(self):
pass
def hands(self):
pass
def feet(self):
pass
A = Person()
assert type(a) is not type(A)
assert not hasattr(a, 'eyes')
a.eyes()
a = 1
simile(a) # Legal (Always)
metaphor(a) # Illegal (Always)
paradox(a) # Illegal (Always)
hyperbole(a) # Illegal (Always)
personification(a) # Illegal (Always)
metonymy(a, 'real') # Legal
metonymy(a, 'imag') # Illegal
i think i only partially understand what you're saying here Jay.
How about this for another metonymy example:
>>> a = []
>>> a.append(a)
>>> a
[[...]]
>>> a[0] is a
True
Or this for paradox:
>>> a = str('nan')
>>> a == a
False
>>> a != a
True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment