Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: I love anonymous functions!

by dragonchild (Archbishop)
on Jun 29, 2004 at 16:57 UTC ( [id://370545]=note: print w/replies, xml ) Need Help??


in reply to Re: I love anonymous functions!
in thread I love anonymous functions!

I am using funcp's, as I said in the original post. The issue is that I want to define those funcp's at runtime. Otherwise, I'm stuck with a kitchen-sink of small functions that have different signatures, which means I'm stuck with one of a few undesirable options:
  1. I create a catchall signature, which is ugly, but manageable
  2. I use void* pointers in my data structure, forcing me to cast all my funcp's. (Would this even work??)
  3. I don't use the same data structure, instead using void* and casting the templated nodes in my array. (Would this even work??)
  4. Use a signature that has varargs in it. But, that's ugly and bypasses a lot of the benefits of using a stronglystatically-typed language. (Would this even work??)

Nope. Give me funcp's every time.

Update:Fixed error as per hardburn's reply.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re^3: I love anonymous functions!
by hardburn (Abbot) on Jun 29, 2004 at 19:27 UTC

    . . . bypasses a lot of the benefits of using a strongly-typed language

    C is not a strongly-typed langauge. Its type system is only useful for hints to the compiler. There are too many ways to subvert it to be anything more. Further, its type errors are just as likely to be annoyances as they are real problems. Rather, C is statically typed, i.e. its types are determined at compile time. Static != strong.

    Perl is more strongly typed than C is. Perl's scalars and lists are very seperate types, and are not so trivial to convert into each other. In fact, it doesn't make sense for there to be a generalized solution for doing list -> scalar.

    Try OcaML. There's a real type system.

    ----
    send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.

Re^3: I love anonymous functions!
by Anonymous Monk on Jun 29, 2004 at 19:03 UTC
    This is where you mix OO and functional constructs. It's staring you in the face. Do it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://370545]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-04-16 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found