예제 #1
0
            public static void Setup()
            {
                var invo = new InvokeableItem();
                var fn   = new Invokeable
                {
                    ReturnType = ItemType.Something,

                    Demands = InvokeableUtils.MakeDemands(
                        InvokeableUtils.DemandOfAnyType(0,
                                                        ItemType.Symbol,
                                                        ItemType.List),
                        args => args.Count == 1),

                    Function = (space, args) =>
                    {
                        var evaluateable = args[0] as EvaluateableItem;

                        var item = evaluateable is SymbolItem
                                                        ? (EvaluateableItem)(Deref(space, evaluateable as SymbolItem) as EvaluateableItem).Unquote()
                                                        : evaluateable;

                        return(item.Evaluate(space));
                    }
                };

                invo.AddInvokeable(fn);
                globalSpace.Bind(";", invo);
            }
예제 #2
0
            public static void Setup()
            {
                var invo = new InvokeableItem();
                var fn   = new Invokeable
                {
                    ReturnType = ItemType.Symbol,

                    Demands = InvokeableUtils.MakeDemands(InvokeableUtils.DemandOfAnyType(0, ItemType.List, ItemType.Symbol)),

                    Function = (space, args) =>
                    {
                        var symbol = args[0] as EvaluateableItem;
                        return(symbol.Quote());
                    }
                };

                invo.AddInvokeable(fn);
                globalSpace.Bind("`", invo);
                globalSpace.Bind("quote", invo);
            }