Replies: 4 comments 10 replies
-
Yes indeed, excellent points! I think it is worth to try add and gain experience with the mechanism implemented in SICStus. I think it would be possible to provide it in addition to what is currently already available in Scryer. In this way, we could try it and see how well it works for the cases needed by Scryer, and if it works well port the existing code to the new mechanism, or an even better one. |
Beta Was this translation helpful? Give feedback.
-
can you possibly provide some examples of what you mean...? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I was recently reading sources from Fifth Generation Computer Systems project, and I found that KL1 language actually supported some sort of macros using wrap#( rational#compose(Real,Image,Out) ) => wrap#( Out= complex(Real,Image) ).
wrap#( rational#complex(Xin) ) => wrap#( Xin= complex(_,_) ) .
wrap#( rational#complex(Xin,Real,Image) ) => wrap#( Xin= complex(Real,Image) ) .
wrap#( rational#real(Xin,Real) ) => wrap#( Xin= complex(Real,_) ) .
wrap#( rational#image(Xin,Image) ) => wrap#( Xin= complex(_,Image) ) .
wrap#( rational#compose(S,Numer,Denom,Out) ) => wrap#( Out= real(S,Numer,Denom) ).
wrap#( rational#rational(Xin) ) => wrap#( Xin= real(_,_,_) ) .
wrap#( rational#rational(Xin,S,Numer,Denom) ) => wrap#( Xin= real(S1,Numer,Denom), S := S1/\1 ) .
wrap#( rational#numer_denom(Xin,Numer,Denom)) => wrap#( Xin= real(_,Numer,Denom) ) .
wrap#( rational#sign(Xin,S) ) => wrap#( Xin= real(S1,_,_), S := S1/\1 ) .
wrap#( rational#numer(Xin,Numer) ) => wrap#( Xin= real(_,Numer,_) ) .
wrap#( rational#denom(Xin,Denom) ) => wrap#( Xin= real(_,_,Denom) ) . I don't know the details, but I can see how it might be implemented from the usages. It looks like during compilation they find occurrences of |
Beta Was this translation helpful? Give feedback.
-
Term expansion is applied to all terms as many times as it is applicable1 in the unspecified order which can lead to highly unpredictable behavior. Goal expansion is better, but still if term expansion is a sledge hammer then goal expansion is a regular hammer. Were ever invented mechanisms that give more control? I know that SICStus for example has additional "tag" that is useful to check which expansions were already applied.
Footnotes
If I get terminology right then it is correct to say that term expansion is applied until fixpoint is found. ↩
Beta Was this translation helpful? Give feedback.
All reactions