Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!lll-winken!lll-tis!ames!pasteur!ucbvax!BOURBAKI.MIT.EDU!ghoti From: ghoti@BOURBAKI.MIT.EDU Newsgroups: comp.lang.c Subject: (none) Message-ID: <8810240528.AA09122@hypatia.mit.edu> Date: 24 Oct 88 05:28:11 GMT Article-I.D.: hypatia.8810240528.AA09122 Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 30 I was writing a program and defined a struct foo as follows: struct foo { int number ; int (*f)() ; } ; It occurred to me that it would be useful to be able to define a function of the following sort: struct foo * tensor_fooze(struct foo foo1,struct foo foo2) { struct foo * spec = (struct foo *) malloc(sizeof(struct foo)) ; spec->number = lcm(foo1.number,foo2.number) ; etc. The catch is that there doesn't seem to be a natural way to define spec->fn [sorry, above I should have written int (*f)() fn ; in the definition of struct foo ] unless I want to let it be a pointer to a function already existing in the C code. I could get around this if there were any kind of facility such as spec->fn = lambda(x){ function body }, but that isn't C . It seems like a desirable feature but how hard is it to implement such a feature ? Alternatively, is there an extension to the C language (e.g. in C++) which lets one pull a stunt like this ? Please address your replies to me directly since I don't subscribe to this mailing list. Thanks. Allan Adler ghoti@cauchy.mit.edu