예제 #1
0
    // A Read-Eval-Send Loop in another thread
    static void RESLoop(SendOut so, BlockingCollection <string> receiveIn)
    {
        var interp = NukataLisp.MakeInterp().Result;

        interp.COut = so;
        for (;;)
        {
            string s = receiveIn.Take();
            if (s == EndSentinel)
            {
                break;
            }
            object x = NukataLisp.Run(interp, new StringReader(s)).Result;
            so.Queue.Add(x);
            so.Queue.Add(EndSentinel);
        }
        so.Queue.Add(EndSentinel);
    }
예제 #2
0
    // Run Lisp in another thread and send it S-expression strings.
    static void Main(string[] args)
    {
        SendOut so    = new SendOut();
        var     queue = new BlockingCollection <string>();

        new Thread(() => RESLoop(so, queue)).Start();
        foreach (string sExpression in new string[] {
            "(cons 1 2)",
            "(print 'Summer)",
            EndSentinel
        })
        {
            queue.Add(sExpression);
            for (;;)
            {
                object x = so.Queue.Take();
                if (x is string s && s == EndSentinel)
                {
                    break;
                }