Re: [Wrapl-discussion] How to invoke such method :"@"?
Brought to you by:
rajamukherji
|
From: Raja M. <raj...@gm...> - 2010-05-29 15:30:21
|
On 29 May 2010 08:14, Roman Mishin <rom...@gm...> wrote:
> In the documentation there are descriptions for methods such as :"@". For
> example, in Libraries:Agg:List there is
> :"+"(a @ T, b @ T) : T
> As I understand, it is possible to invoke this as
> a:"+"(b);
> and in its natural form:
> a + b;
>
Yes, that's right.
My question is how to propagate this rule to methods which description looks
> like this:
> :"@"(list @ T, _ = Std.String.T, sep @ Std.String.T) : Std.String.T
>
There is one character @ denotes an operator(method) and there are three
> arguments. How to combine them in a call?
>
I want something similar to:
> VAR text <- mylist@" "; Out:write(text);
> I get:
> Modname.wrapl(1): no method: @
>
An @ in a method description matches the type of an argument, whereas =
matches the value. So the code would be
VAR text <- mylist@String.T;
To call @ with three arguments, you can use for example
:"@"(mylist, String.T, " ")
You can also use
mylist@(String.T, " ")
but I'm not very happy with this syntax and am still open to suggestions
about changing it.
> Here is the code of what I want to accomplish:
>
> MOD Bottles;
>
> IMP IO.Terminal USE Out;
> IMP Std.String;
> IMP Std.List;
>
> DEF ob <- "of beer", otw <- "on the wall";
> VAR verse <- [], more <- "Take one down and pass it around", s <- "s", i;
>
> EVERY i <- 9:to(0,-1) DO (
> s <- ((2 > i) + 1)("s", "");
> (i = 0) & (i <- "No more"; more <- "Go to the store and buy some more");
> verse:put('. {i} bottle{s} {ob} {otw}.\n');
> verse:put('\n{i} bottle{s} {ob} {otw}, {(i@String.T):lower} bottle{s}
> {ob}.\n{more}');
> );
>
> -- EVERY Out:write(verse[2,0]:values); Out:write(verse[1]);
> VAR Verse <- verse@" "; Out:write(Verse);
>
> END Bottles.
>
> And further question:
>
> This command succeeds in Interactive Wraple:
> --> ? mylist;
> C:\Wrapl\lib\Agg\List.T
>
> But the following does not:
> --> Out:write(? mylist);
> Unhandled message: no method: @
>
> Why not and why @ again?
>
After each calculation, the Wrapl interpreter tries to convert the result to
a string (using "value @ String.T") to display. However, if it can't be
converted to a string (types and functions for example), then it tries to
see if the value is a global variable/constant exported from a module (using
functions in Sys.Module) and displays the module name and the symbol name.
Out:write(value) also tries to convert value to a string using @ but if it
can't, it simply returns an error.
> --
> Roman
>
By the way, you're the first person to seriously try using Wrapl, so the
online documentation may be a bit lacking in places. I'll try to improve it
based on your comments.
Also, the Windows port of Wrapl is a bit out of date, I don't think any of
the versions of @ with 3 or more arguments are implemented in it. Since your
last comment, I have mostly fixed the Windows port and will put the new
version on the website within the next week.
Raja
------------------------------------------------------------------------------
>
>
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
>
|