dynamic-binding

Function name and dynamic binding in Common Lisp

大兔子大兔子 提交于 2019-12-07 23:57:59
问题 I'm reading Peter Norvig's Paradigms of AI . In chapter 6.2, the author uses code like below ( not the original code, I picked out the troubling part ): Code Snippet: (progv '(op arg) '(1+ 1) (eval '(op arg))) As the author's original intent, this code should return 2 , but in sbcl 1.1.1 , the interpreter is apparently not looking up op in the environment, throwing out op: undefined function . Is this implementation specific? Since the code must have been tested on some other lisp. p.s

Function name and dynamic binding in Common Lisp

孤者浪人 提交于 2019-12-06 10:09:59
I'm reading Peter Norvig's Paradigms of AI . In chapter 6.2, the author uses code like below ( not the original code, I picked out the troubling part ): Code Snippet: (progv '(op arg) '(1+ 1) (eval '(op arg))) As the author's original intent, this code should return 2 , but in sbcl 1.1.1 , the interpreter is apparently not looking up op in the environment, throwing out op: undefined function . Is this implementation specific? Since the code must have been tested on some other lisp. p.s Original code You probably mean (progv '(op arg) '(1+ 1) (eval '(funcall op arg))) Edit(2013-08-21): PAIP was

DLR return type

橙三吉。 提交于 2019-12-05 22:37:46
问题 I need some DLR help. I am implementing an IDynamicMetaObjectProvider and DynamicMetaObject but I am having some issues getting the expected return type. I am overiding BindInvokeMember in the metaobject, I can see all the args types but no return type. Anyone know how I get to it if possible? I know the return type is dynamic but what if the thing you are invoking is dependent on a return type. I don't know which action to perform in the DynamicMetaObject unless I know the return type the

Guice : Set bindings from an XML file

删除回忆录丶 提交于 2019-12-05 22:28:08
I'm trying to use Guice and make all the bindings with the help of an XML file. In my module (let's say "CustomModule"), I would like to load an XML file and parse it to set all the bindings. I'm able to load the XML file and retrieve all the values needed (below is an exemple of my XML file), but I'm unable to use those values to bind(interfaceValue).to(implementationValue); . What I've tried so far: Load the XML file, retrieve all the values and use them as : bind(Class.fromName(Ivalue)).to(Class.fromName(Value)); where Ivalue is InterfaceFoo and Value is Foo . Load the XML file as a

C++ overridden function not called

余生颓废 提交于 2019-12-04 06:24:32
问题 I am running into an issue where an overloaded function is not called, and the base function is called instead. I suspect this is related to how things are split between the project files. In files obj1.h/obj1.cpp I have something like this class obj1{ public: void print(); }; void obj1::print(){ cout << "obj1::print()"; } In files obj2.h/obj2.cpp I have something like this: #include "obj1.h" class obj2 : public obj1{ public: void print(); }; void obj2::print(){ cout << "obj2::print()"; } In

interface paradigm performance (dynamic binding vs. generic programming)

拟墨画扇 提交于 2019-12-04 04:32:51
While at their core dynamic binding and templates are fundamentally different things, they can be used to implement the same functionality. Code example (only for reference) A) dynamic binding namespace DB { // interface class CustomCode { public: virtual void operator()(char) const = 0; }; class Lib { public: void feature(CustomCode const& c) { c('d'); } }; // user code class MyCode1 : public CustomCode { public: void operator()(char i) const { std::cout << "1: " << i << std::endl; } }; class MyCode2 : public CustomCode { public: void operator()(char i) const { std::cout << "2: " << i << std:

DLR return type

跟風遠走 提交于 2019-12-04 04:21:27
I need some DLR help. I am implementing an IDynamicMetaObjectProvider and DynamicMetaObject but I am having some issues getting the expected return type. I am overiding BindInvokeMember in the metaobject, I can see all the args types but no return type. Anyone know how I get to it if possible? I know the return type is dynamic but what if the thing you are invoking is dependent on a return type. I don't know which action to perform in the DynamicMetaObject unless I know the return type the consumer is expecting. Update Two I cant paste my actual code here since it calls all kinds of work stuff

Higher-order functions in Elisp

佐手、 提交于 2019-12-03 12:38:24
I created a function that returns a function in Elisp: (defun singleton-set (elem) (defun f (n) (= n elem)) f) I try to run this in IELM, and it fails: ELISP> (singleton-set 5) *** Eval error *** Symbol's value as variable is void: f ELISP> ((singleton-set 5) 5) *** Eval error *** Invalid function: (singleton-set 5) Due to What is the difference between Lisp-1 and Lisp-2? i changed the code to (defun singleton-set (elem) (defun f (n) (= n elem)) #'f) And invocation to (funcall (singleton-set 5) 5) , but now the error is *** Eval error *** Symbol's value as variable is void: elem I understand

Dynamically binding lists with Spring's form tag

喜欢而已 提交于 2019-12-03 08:26:44
问题 I have a command object FaxForm and it holds a list of FaxStatus objects inside a faxStatusList property. public class FaxForm { private List<FaxStatus> faxStatusList; public void setFaxStatusList(List<FaxStatus> faxStatusList) { this.faxStatusList = faxStatusList; } public List<FaxStatus> getFaxStatusList() { return faxStatusList; } } I initially had a JSP page that would bind the objects by performing the following: <c:forEach items="${esaFaxForm.faxStatusList}" var="item" varStatus="loop">

Dynamically binding lists with Spring's form tag

旧街凉风 提交于 2019-12-02 21:03:16
I have a command object FaxForm and it holds a list of FaxStatus objects inside a faxStatusList property. public class FaxForm { private List<FaxStatus> faxStatusList; public void setFaxStatusList(List<FaxStatus> faxStatusList) { this.faxStatusList = faxStatusList; } public List<FaxStatus> getFaxStatusList() { return faxStatusList; } } I initially had a JSP page that would bind the objects by performing the following: <c:forEach items="${esaFaxForm.faxStatusList}" var="item" varStatus="loop"> <tr class="tableAltBackground"> <td> <form:checkbox path="faxStatusList[${loop.index}].selected"/> <