-
Notifications
You must be signed in to change notification settings - Fork 6
Kind of static type checking? #4
Comments
sorry, there is a typo, try inline d - generic-function please! I'll fix it now. |
Oh, I was still wrong. The function was without d. This is not good ... |
I also found that it looks like somwhere between SBCL 1.3.5 and 1.3.8 the unit-tests starts to fail. For example, tests for |
What a shame! the error was due to the change in |
now both package/symbol export issue and unit-test issue is resolved. |
We have a bad news and a good news. I-G-F can signal no-primary-method, but this happens in runtime. At first I tested what happens if I shadow a function with a local macro. However, branch pruning happens in IR of the implementation, thus normal macros/macrolets do not work. In order to modify the behavior depending on whether the branch is pruned or not, you should dive into IR1.
|
Hi, thanks a lot for the quick help! An idea that I had during the night was to define some function ( IMO some implementation-specific magic is surely allowed, as this is a useful feature... so please, take the With that example it should be easy to get a few more solutions for other implementations on #lisp - and if not every one has a way to give compile-time-errors, then the runtime-error will have to be sufficient anyway. Thank you!! |
Using #+sbcl we can disable the deftransform on other impls. So we can guarantee that when it compiles on sbcl it is safe on other implementations as well. |
but the saveat for this is that every method definitions should be already defined at compile-time. Thus I won't make it a default although I may provide a flag that automatically appends such an ir1-error. |
Yeah. The reason for some public name is to easily disallow some specific combinations: (defmethod plus ((a number) (b number))
(+ a b))
(defmethod plus ((a string) (b string))
(concatenate 'string a b))
(defmethod plus ((a number) (b string))
(inlined-g-f:invalid-branch))
(defmethod plus ((a string) (b number))
(inlined-g-f:invalid-branch)) |
BTW, is there a way to restrict the inlining to some maximum depth? In case a method wants to call another method (eg. after argument conversion) simply inlining again leads to a stack exhaustion... |
IGF recognizes |
So, (defmethod a ...
(declare (notinline a))
...
(a ...)) should be able to avoid inifinite recursion. |
|
Temporarily added INVALID-BRANCH and testing against various SBCL versions. |
Thank you very much! Yeah, having that in |
Hi,
first of all,
This symbol is not exported, and not even defined in my QL (
inlined-generic-function-20160628-git
).Furthermore, I tried to get some static type checking. With a default method (that might be a default of
inlined-generic-function
even?) ofI get
variable defined but not used
in call sites that might use that, but a more descriptive message would be better. Do you see any way to get a compile time error with a useful message?Thank you very much!
The text was updated successfully, but these errors were encountered: