Name that function

schwern on 2008-09-30T12:51:06

I got an obvious feature request for Method::Signatures to make it work for normal functions. I haven't stoked mst's brain with enough drugs yet to have Devel::Declare override sub, so it would have to use another name. What would it be?

"def", "fun", "func", "function", "subroutine", "coke" (ya know, fish for corporate sponsorship)?

A tangentially related problem is once we do know how to override "sub" what is the syntax to use signatures and prototypes together? One answer is "don't", leave "sub" as is and use a new keyword. But as awful as prototypes are, they have their uses.


fun!

awwaiid on 2008-09-30T14:32:42

I like the /fun.*/ variants, 'fun' being my favorite.

    fun add($x, $y) { $x + $y }

or perhaps

    $add = fun($x, $y) { $x + $y }

eh? nice and short. Though now that I look at it, 'func' might be slightly more readable for the uninitiated. But they might have other problems with this fun insanity!

great!

jk2addict on 2008-09-30T16:52:22

now I have this song in my head...

"...conjunction junction, what's your function..."

procedure ;-)

rhesa on 2008-09-30T17:16:32

I'd like to see "function" (or a variant) reserved for something carrying some promise of being side-effect free. That'd be useful for functional programming.

I'd suggest "procedure" or something like it for ordinary subs. I wouldn't even consider trying mixing prototypes and signatures, so I'd like to keep "sub" as is.

That way, you've covered three major programming styles.

Re:procedure ;-)

drhyde on 2008-10-01T11:07:37

The old BBC BASIC programmer in me thinks that proc would work nicely.

Short is good

educated_foo on 2008-09-30T17:36:58

I'd like to keep it short, i.e. "fun" or "def". "procedure" feels like lower-case COBOL.

lambda

djberg96 on 2008-09-30T17:45:31

lambda, lambda, lambda

(or, you could use the actual greek symbol)