Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

lisp-like backquotes macros

 [1/12] from: henri:morlaye:gma:il at: 26-Nov-2005 0:49


Hello, Am I the only one who find the lispy backquote macros better than the COMPOSE function ? for example: `[ ,value1 to-string ( to-integer ,value2 ) + 2 ) ] instead of: compose/deep [ (value1) to-string (to-paren reduce[ to-paren reduce [ 'to-integer (value2) ] + 2 ] ] Why is it so ? -- henri

 [2/12] from: volker:nitsch:gmai:l at: 26-Nov-2005 1:06


On 11/26/05, Henri Morlaye <henri.morlaye-gmail.com> wrote:
> Hello, > Am I the only one who find the lispy backquote macros better than the
<<quoted lines omitted: 5>>
> 'to-integer (value2) ] + 2 ] ] > Why is it so ?
Because you used an artificial example? Parens *are* the backquotes of rebol. What happens if you want to backquote backquotes in lisp? (I admit in some cases, like composing parse-rules, your example makes sense.).
> -- > henri > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. >
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [3/12] from: henri:morlaye:gma:il at: 26-Nov-2005 1:17


This example comes out of a real problem I have, it is not artificial (it may not be good rebol however ). Parens are also used to prioritize calculus, so every time I want to build a function block, there is a clash between priorities parens and compose parens. -- henri On 11/26/05, Volker Nitsch <volker.nitsch-gmail.com> wrote:

 [4/12] from: lmecir::mbox::vol::cz at: 26-Nov-2005 1:33


Hi Henri, ...
>Parens are also used to prioritize calculus, so every time I want to >build a function block, there is a clash between priorities parens and >compose parens. > >-- >henri >
welcome to the list. Have a look at Build dialect http://www.fm.vslib.cz/~ladislav/rebol/build.r , if you find Compose dialect unacceptable. -L

 [5/12] from: volker:nitsch:gm:ail at: 26-Nov-2005 4:41


On 11/26/05, Henri Morlaye <henri.morlaye-gmail.com> wrote:
> This example comes out of a real problem I have, it is not artificial > (it may not be good rebol however ). >
Then i was to harsh, sorry. Ladislavs site is currently down, he mentioned some domai-rename in another post. Googled and found a %build.r here: http://www.pat665.free.fr/gtk/rebol-core.html#sect22. (for the few hours until he fixes that)
> Parens are also used to prioritize calculus, so every time I want to > build a function block, there is a clash between priorities parens and
<<quoted lines omitted: 47>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

 [6/12] from: lmecir::mbox::vol::cz at: 26-Nov-2005 9:03


Volker Nitsch napsal(a):
>On 11/26/05, Henri Morlaye <henri.morlaye-gmail.com> wrote: >>This example comes out of a real problem I have, it is not artificial
<<quoted lines omitted: 8>>
>http://www.pat665.free.fr/gtk/rebol-core.html#sect22. >(for the few hours until he fixes that)
This looks like a DNS problem. Currently there are two domain names and I don't know which one will work for you. www.fm.tul.cz should be the new one, but you may try www.fm.vslib.cz instead to see if it works -L

 [7/12] from: gabriele:colellachiara at: 26-Nov-2005 11:46


Hi Henri, On Saturday, November 26, 2005, 12:49:43 AM, you wrote: HM> `[ ,value1 to-string ( to-integer ,value2 ) + 2 ] Probably Ladislav's BUILD will help; anyway, sometimes it is possible to refactor your code so that you don't need it. In the case above, for example, you could write: compose [(value1) to-string 2 + (to-integer value2)] (Well, actually, in this specific case you could just write: reduce [value1 to-string 2 + to-integer value2] because there's no reason to do the add and the string conversion at "runtime", but I assume it's just because this is a simplified example.) Also, REBOL offers another way to obtain the same goal without composing at all. use [value1' value2'] [ value1': value1 value2': to-integer value2 [value1' to-string value2' + 2] ] Using a function like my LOCALIZE in: http://www.colellachiara.com/soft/Libs/utility.r localize [value1 value2] [ [value1 to-string 2 + to-integer value2] ] The solutions here do not solve all the cases, especially when you are composing PARSE rules; but they can give you ideas. Regards, Gabriele. -- Gabriele Santilli <gabriele-rebol.com> --- http://www.rebol.com/ Colella Chiara software division --- http://www.colellachiara.com/

 [8/12] from: henri:morlaye::gmail at: 26-Nov-2005 13:19


> Probably Ladislav's BUILD will help; anyway, sometimes it is > possible to refactor your code so that you don't need it.
<<quoted lines omitted: 5>>
> at "runtime", but I assume it's just because this is a simplified > example.)
I don't want it to be done at runtilme. The value is in fact the name of a variable, I create a standard block for a standard function, and then I create several functions using different variables by replicating/compositing the standard block.
> Also, REBOL offers another way to obtain the same goal without > composing at all.
<<quoted lines omitted: 10>>
> The solutions here do not solve all the cases, especially when you > are composing PARSE rules; but they can give you ideas.
Thank you very much, utility.r and build.r are nice, I will probably find a solution with them, nevertheless they all seem like workarounds for the lack of backquotes macros, I still don't understand why RebolTech decided to use parens for compose. The lispy method seems so much more comfortable, and more accurate with the use of "-" only when needed instead of the "/only". -- henri

 [9/12] from: gabriele::colellachiara::com at: 26-Nov-2005 14:29


Hi Henri, On Saturday, November 26, 2005, 1:19:18 PM, you wrote: HM> I don't want it to be done at runtilme. The value is in fact the name HM> of a variable, I create a standard block for a standard function, and HM> then I create several functions using different variables by HM> replicating/compositing the standard block. Do you mind sharing the actual examples? HM> Thank you very much, utility.r and build.r are nice, I will probably HM> find a solution with them, nevertheless they all seem like workarounds HM> for the lack of backquotes macros, I still don't understand why HM> RebolTech decided to use parens for compose. The lispy method seems so HM> much more comfortable, and more accurate with the use of "-" only when HM> needed instead of the "/only". But REBOL has no syntax, in the way Lisp does. So the way to do that in REBOL is creating a dialect, like the BUILD function. Since REBOL is more dynamic than Lisp (REBOL cannot be compiled, while Lisp is a compilable language), it does not need macros as much as Lisp does; so the need for a dialect like BUILD is not that strong, and that's why it's not built in. It has to be said, that while you would not be able to really do macros in Lisp without having quoting, i.e. without support in the syntax, you can do all that in REBOL without any special support. Regards, Gabriele. -- Gabriele Santilli <gabriele-rebol.com> --- http://www.rebol.com/ Colella Chiara software division --- http://www.colellachiara.com/

 [10/12] from: henri:morlaye:g:mail at: 26-Nov-2005 16:38


You are right, rebol is about dialects after all, and Ladislav's BUILD function does the job very well (especially with the /with refinement). However the built-in COMPOSE function is not inspired by a dialected way of doing things, it looks more like the lispy backotes+comma. I think it should either be more comfortable like lisp, or completely rebolesque like Build. -- Henri On 11/26/05, Gabriele Santilli <gabriele-colellachiara.com> wrote:

 [11/12] from: lmecir:mbox:vol:cz at: 26-Nov-2005 17:44


Henri Morlaye napsal(a):
>You are right, rebol is about dialects after all, and Ladislav's BUILD >function does the job very well (especially with the /with
<<quoted lines omitted: 4>>
>-- >Henri
COMPOSE is not comfortable, indeed. What is needed is a good dialect. Any inspiration in that direction welcome, because sometimes it is much harder to invent a good dialect than to implement it. -L

 [12/12] from: volker:nitsch:g:mail at: 26-Nov-2005 18:59


On 11/26/05, Henri Morlaye <henri.morlaye-gmail.com> wrote:
> > Probably Ladislav's BUILD will help; anyway, sometimes it is > > possible to refactor your code so that you don't need it.
<<quoted lines omitted: 39>>
> much more comfortable, and more accurate with the use of "-" only when > needed instead of the "/only".
Deep lisp-magic? :) RT does not support backquotes IMHO because in rebol we rarely do it that deep. Rebol has other ways, contexts and parse-rules (dialects). I for example use Compose only for small parts (IMHO else /deep would be the default ;) Your Lisp-example: `[ ,value1 to-string ( to-integer ,value2 ) + 2 ) ] You want a lot of functions like that. functions that look like f: func[][ value1 to-string ( to-integer value2 ) + 2 ] Done like this: ctx: context [ value1: value2: none f: func [] [value1 to-string (to-integer value2) + 2] ] o1: make ctx [value1: "v1" value2: "1"] o2: make ctx [value1: "v2" value2: "22"] o1/f ; == "3" o2/f ; == "24" Has an advantage in rebol, because we have side-effects here. The values can be changed after the closure is bound, so inlining them makes less sense. So i put dynamic values in the context and use unmodified clones of the template-functions. Not like lisp, where you are build the functions and keep data by closure-bindings. I can build code too, but because of such reasons such functions are shorter and 'compose can handle them. Also there is no build-code-phase. Usually i dont compile, i work directly on the data. So clever macro-support is not that important. If i need something complex, i write a whole grammar. Maybe more verbose than backquote-macros, if i want to build code. But i do not, such a grammar is applied each time to the actual data. The data is stored efficiently in rebol-values of course, not each time parsing strings. That "compiling" of data by 'load, and the block-parser, can often compete with pre-build code. I dont use 'compose that much to build functions, but to build data. Rebol-data contains meta-information: keywords, datatypes etc. msg: compose [message reply "lisp" (now)] ; == [message reply "lisp" 26-Nov-2005/18:48:55+1:00] Part of many dialects is that datatypes have meaning. Parens in compose. Or function-headers: refinements have the meaning of optional arguments, blocks of type-declarations, strings of comments etc. parse msg [any [ arg: 'message word! (print ["type" arg/2]) | string! (print ["subject" arg/1]) | date! (print ["date" arg/1]) ]] I don't build a function here, i parse data. And compose helps building them. For a clever generic dialect have a look at Ladislavs 'build. He basically implements backquoting. The backquotes are 'insert and 'only. And its not that much code. (Although a lot rebol-knowleddge :)
> -- > henri > -- > To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject. >
-- -Volker Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem. David Wheeler

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted