LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-10-2008, 11:38 AM   #1
cleopard
Member
 
Registered: May 2006
Posts: 39

Rep: Reputation: 15
continuation


I've been trying to understand the concept of continuation passing style and I get it to a point. But most of the code examples I find are in languages that I'm not familiar with, such as Scheme. CPS can apparently be used with C and if I could find some code examples in C, that would help a lot. And if anyone could make book suggestions (I've done some searching on Safari and Amazon, and saw a couple that might deal with this topic on some level) or any other sources, that would be great, too.
 
Old 04-10-2008, 12:16 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
I think making it work in C would also require a return statement, or just void functions:
Code:
void function2(int aArg)
{
    //...
}
 
void function1(int aArg)
{
    //...
    function2(aArg);
}
 
int main()
{
    //...
    int control;
 
    function1(control);
}
C isn't designed well for that because while function2 is running, the items on the stack belonging to function1 and main are still there, even though you don't intend to use them again.
ta0kira

Edit: You can overcome the stack problem like this:
Code:
void function1(int aArg)
{
    {
    //...
    }
 
    function2(aArg);
}
There will be an argument left on the stack for each time control is passed, but at least that's uniform and predictable.

PS I just learned this in response to your question, so I may have misinterpreted the concept.

Last edited by ta0kira; 04-10-2008 at 12:31 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
continuation - usb or ethernet modem connection joel b Fedora 9 02-21-2005 04:07 AM
wget continuation problem ksd Linux - Software 2 10-20-2003 10:51 AM
p4pe sound problem continuation shadeXIII Linux - Hardware 1 06-06-2003 10:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration