Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Ways to implement a closure

by SpanishInquisition (Pilgrim)
on Oct 18, 2004 at 19:50 UTC ( [id://400297]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Ways to implement a closure
in thread Ways to implement a closure

C does not have templates OR classes! (Not that this is a bad thing...)

Replies are listed 'Best First'.
Re^5: Ways to implement a closure
by ikegami (Patriarch) on Oct 18, 2004 at 20:05 UTC
    Oops, I often call C++ by the wrong name. But while the code was C++, the argument does work for C as well. Here's the C version of the C++ snippets:
    HASH* demonstration(void* p) HASH* hash_ptr = hash_new() hash_add(hash_ptr, "demo_data", p); HASH* outer_hash_ptr = hash_new(); hash_add(outer_hash_ptr, "demonstration_data", hash_ptr); return outer_hash_ptr; }

    and

    HASH* demonstration(void* p) HASH hash; hash_init(&hash); hash_add(&hash, "demo_data", p); HASH* outer_hash_ptr = hash_new(); hash_add(outer_hash_ptr, "demonstration_data", &hash); XXX BUG return outer_hash_ptr; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-25 15:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found