wrapl-discussion Mailing List for Wrapl Programming Language
Brought to you by:
rajamukherji
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
(8) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
(6) |
Jul
(4) |
Aug
(3) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Roman M. <rom...@gm...> - 2014-08-28 13:37:24
|
Hi Raja, I noticed there is new announcement on the Wrapl's home page. I kindly glad you are still working on it. There is Windows build mentioned on the Download page. http://downloads.sourceforge.net/wrapl/wrapl-3.10.1216M.exe But the link leads nowhere. It seems broken. If possible, could you, please, upload the file? -- Roman |
|
From: Roman M. <rom...@gm...> - 2010-09-03 11:25:09
|
Hi :) TO :puzzle(list @ List.T) ALL PROD list:copy:delete(list:keys):values; A silly example, perhaps. And this version, probably, won't work (given two generators). I want to show that such a long construct makes a kind of data-flow with list data. I can terminate it where I want (i.e., I transform the structure and then - stop, at this point I want to get its :values). But :delete' behaviour breaks that flow. That is unexpected - partially because it is not in line with other list methods, and partially because I didn't intend to get the value(s) at this point. And there are no methods to delete, returning a list. Obviously, there are cases where the list is desirable as well as cases where the value is. WITH removed_item <- cache:remove(items_by_date()) DO (...); WITH item <- cache:find(items_by_date()) DO (... => cache:delete(item)); Would you agree that cache resembles a stack-like structure? With the stack style it is expected (IMO) to get the value when it is removed. Would it be an option then to have additional :drop and :pick (or :peek) stack-style methods that behave like current :delete and :remove do, but put :delete and :remove in line with other list-style methods and with Table module and have them return the list. I mean there already are two kinds of behaviour in List module: stack-style and list-style (:push, :put) == :insert; (:pop, :pull) == :delete; I propose to have (:pop, :drop, :pick, :pull) == (:delete, :remove) equivalence, were: :drop(list @ T, n @ Std.Integer.SmallT) : ANY - takes index and returns value; :pick(list @ T, value) : ANY - takes value and returns value; :delete(list @ T, n @ Std.Integer.SmallT) : T - takes index and returns list; :remove(list @ T, value) : T - takes value and returns list; I do not know how this affects your code and you could argue the names. |
|
From: Raja M. <raj...@gm...> - 2010-09-03 06:10:36
|
Hi Roman,
> Do you think it is practical to return the removed value from
> list:delete and
> list:remove methods? I mean, instead of returning the remaining list.
> Perhaps, you have already wrote some working code that uses these
> methods that
> way. What are your reasons?
>
> My thoughts:
> --------------------------------------------------------------------------------
> :copy, :empty, :insert, :reverse, :shift, :sort - all return the
> modified list.
> Why :delete and :remove should return the value?
I think when I wrote :delete for lists, I wanted it to return the
corresponding removed value for efficiency, the value can be used
without a separate index operation first. I also had this in mind for
:delete on tables, but ended up returning the table there instead. I
think that :delete should be consistent across lists/tables, but I'm
still of the opinion that the removed value should be returned in both
cases.
> :pop, :pull, :push, :put - are stack-style methods - they shouldn't be
> a pattern.
>
> In case of list:remove the value to be removed is already known to be
> returned.
As for :remove, if the removed value is returned from a generator, it
won't be known before it is removed. Since :remove fails if no matching
value is found, I think it's more appropriate to return the value rather
the list/table. For example,
WITH removed_item <- cache:remove(items_by_date()) DO (
...
);
where items_by_date() generates values that may be in cache.
What do you think of this reasoning? Of course, I intend of making the
behaviour consistent between tables and lists.
> As an example:
> --------------------------------------------------------------------------------
> If :delete returns a list, this programming challenge:
> http://www.reddit.com/r/programming/comments/2xdkd/google_interview_questions/c2xe85
> could be solved in one line:
>
> TO :puzzle(list @ List.T) ALL :"*":foldl(ALL list:copy:delete(list:keys));
> -- or
> TO :puzzle(list @ List.T) ALL PROD list:copy:delete(list:keys):values;
>
> [1, 2, 3, 4, 5]:puzzle;
Hmmm, solving a Google programming challenge in one line sounds fun, but
it's not enough to convince me. Now you can have the challenge of
solving it in one line if :delete returns the value instead :)
> By the way, there is a typo in :shift description:
> --------------------------------------------------------------------------------
> :shift(list @ T, n @ Std.Integer.SmallT, r @ Std.Integer.SmallT) : T
> shifts the nth element by n positions within list
> ->
> shifts the nth element by r positions within list
Thanks for this (and the previous typos/errors). I've encountered a
small problem while upgrading the Hans Boehm garbage collector to the
latest CVS version, but as soon as that's resolved, I'll release a new
version with all these fixes.
Raja
|
|
From: Roman M. <rom...@gm...> - 2010-09-02 09:43:18
|
Raja, Do you think it is practical to return the removed value from list:delete and list:remove methods? I mean, instead of returning the remaining list. Perhaps, you have already wrote some working code that uses these methods that way. What are your reasons? My thoughts: -------------------------------------------------------------------------------- :copy, :empty, :insert, :reverse, :shift, :sort - all return the modified list. Why :delete and :remove should return the value? :pop, :pull, :push, :put - are stack-style methods - they shouldn't be a pattern. In case of list:remove the value to be removed is already known to be returned. As an example: -------------------------------------------------------------------------------- If :delete returns a list, this programming challenge: http://www.reddit.com/r/programming/comments/2xdkd/google_interview_questions/c2xe85 could be solved in one line: TO :puzzle(list @ List.T) ALL :"*":foldl(ALL list:copy:delete(list:keys)); -- or TO :puzzle(list @ List.T) ALL PROD list:copy:delete(list:keys):values; [1, 2, 3, 4, 5]:puzzle; By the way, there is a typo in :shift description: -------------------------------------------------------------------------------- :shift(list @ T, n @ Std.Integer.SmallT, r @ Std.Integer.SmallT) : T shifts the nth element by n positions within list -> shifts the nth element by r positions within list -- Roman |
|
From: Roman M. <rom...@gm...> - 2010-08-27 05:35:25
|
Hi Raja, here are two small observations for the upcomming release: -------------------------------------------------------------------------------- http://wrapl.sourceforge.net/ref/tutorial/chapter6.html A typo: closet -> closest -------------------------------------------------------------------------------- Agg.List :delete(list @ T, n @ Std.Integer.SmallT) : T this method actually returns deleted element, not the remaining list. -- Roman |
|
From: Raja M. <raj...@gm...> - 2010-08-12 18:39:11
|
Hi Roman, Thanks for pointing out the error in the tutorial. The implementation is correct though, ALL 1:to(3) \ 10:to(12); should return [1, 1, 1, 2, 2, 2, 3, 3, 3], the values of (left for each right). This follows the general rule of left-to-right evaluation in Wrapl. In general A & B is equivalent to 2(A, B) and A \ B is equivalent to 1(A, B). The description in the tutorial is ambiguous though, I'll update the description along with the other changes you mentioned previously. Raja Roman Mishin wrote: > Hi Raja, > > I noticed one small inconsistency with "expr1 \ expr2" > > Tutorial Chapter 3 > (http://wrapl.sourceforge.net/ref/tutorial/chapter3.html) > > "expr1 \ expr2 produces the values produced by expr1 for each value > produced by expr2" > > ALL 1:to(3) \ 10:to(12); > actualy returns > [1, 1, 1, 2, 2, 2, 3, 3, 3] > not > [1, 2, 3, 1, 2, 3, 1, 2, 3] > as the example shows > > Tutorial states that "expr1 \ expr2" is similar to "expr1 & expr2", > such that it returns the value of left for each right, in contrast to > the value of right for each left. But that (factual) way their (& and > \) results are not symmetrical. > > -- > the values of (left for each right) [1, 1, 1, 2, 2, 2, 3, 3, 3] > vs. > (the values of left) for each right [1, 2, 3, 1, 2, 3, 1, 2, 3] > -- > > I guess it would make sense for it to behave that way: [1, 2, 3, 1, 2, > 3, 1, 2, 3] > > -- > Roman > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > ------------------------------------------------------------------------ > > _______________________________________________ > Wrapl-discussion mailing list > Wra...@li... > https://lists.sourceforge.net/lists/listinfo/wrapl-discussion > |
|
From: Roman M. <rom...@gm...> - 2010-08-12 11:27:46
|
Hi Raja, I noticed one small inconsistency with "expr1 \ expr2" Tutorial Chapter 3 (http://wrapl.sourceforge.net/ref/tutorial/chapter3.html) "expr1 \ expr2 produces the values produced by expr1 for each value produced by expr2" ALL 1:to(3) \ 10:to(12); actualy returns [1, 1, 1, 2, 2, 2, 3, 3, 3] not [1, 2, 3, 1, 2, 3, 1, 2, 3] as the example shows Tutorial states that "expr1 \ expr2" is similar to "expr1 & expr2", such that it returns the value of left for each right, in contrast to the value of right for each left. But that (factual) way their (& and \) results are not symmetrical. -- the values of (left for each right) [1, 1, 1, 2, 2, 2, 3, 3, 3] vs. (the values of left) for each right [1, 2, 3, 1, 2, 3, 1, 2, 3] -- I guess it would make sense for it to behave that way: [1, 2, 3, 1, 2, 3, 1, 2, 3] -- Roman |
|
From: Raja M. <raj...@gm...> - 2010-07-22 07:53:49
|
Roman Mishin wrote:
>
> The :collect method in Agg.List is actually a method on functions,
> but defined in Agg.List since it returns a list. I guess there
> could be another similar method for tables, like :collect_table.
>
>
> I missed that point too (that it comes from Functions). Frankly, I do
> not really want it to be named :collect_table. Let's defer this until
> a practical urge? If you'll implement it I'll vote it to be called by
> a single word, i.e. :glean, :sieve or other English verb that is a
> form of thorough gathering/collecting, since the result will be
> unique, sorted values.
I'll leave it out for now so, I think the Table.Collect function call is
sufficient for the moment.
>
> UNIQ expr sounds like an interesting idea, but it can be done in
> code as (VAR t <- {}; EVERY t:insert(expr); t), just as (VAR l <-
> []; EVERY l:put(expr); l) will emulate ALL expr. The main reason
> for ALL expr is that directly appending to a list is a lot faster
> than the the overhead of calling l:put(expr). ALL expr is
> effectively a more powerful form of list comprehensions, already
> found in languages like Python. While the time to call
> t:insert(expr), would be removed by a UNIQ expr, the call to :"#"
> (to hash the value) and :"?" (to compare values) when inserting
> into the table would still be present. If you think it would be
> useful however, I'll implement it, it wouldn't be hard since I can
> reuse the ALL code.
>
>
> I see ALL expr from such perspective that it makes the code clear and
> in some sense semantically complete. It's if I'd say: I want here all
> expr's values. I proposed UNIQ from that point of view.
>
> Here are three files: a small task where this comes from. The first
> one (Unique1) was created initially. It looks too general. Then I
> imagined it could be done with UNIQ (Unique2). You suggest it can be
> done the third way (Unique3) and to me it looks clear but is not
> a straight way to express the notion.
>
> I would agree on UNIQ implementation even without a performance gain,
> only because of the syntax.
I forgot to mention one other reason why I didn't have such a thing
before, the code VAR t <- {}; creates a normal table, but if Agg.Table
is imported, the code VAR t <- Table.New(comparefn, hashfn); creates a
table with custom comparison and hashing functions (instead of the
multimethods :? and :#), which can be faster if the type of the keys is
known in advance (for example using String.Compare and String.Hash
directly), or provide different sorting on the keys, etc. There is no
equivalent concept for lists.
But you're right, consistency has the highest priority in designing
Wrapl, and a UNIQ expression would mirror the ALL expression perfectly.
For situations where using custom comparison/hash functions is
necessary, the previous method of using an explicit variable will always
be available anyway.
I'll set about implementing it for the next release.
> --
> Roman
Raja
|
|
From: Raja M. <raj...@gm...> - 2010-07-20 23:11:25
|
Hi Roman,
Thanks for the suggestions, the typos have be fixed locally, the website
will be updated in a few days once I finish a few other improvements I
have been working on. I will try to finish the main tutorial and write a
proper GTK+ tutorial, but that might take a little while. In the
meantime, the source of Wredit (in dev/src/Wredit in the source
download) might serve as an example.
The temporary filenames on Windows are coming from Cygwin, so I guess it
makes sense for them to have UNIX-style names. However without a full
Cygwin installation, I'm not sure where /tmp will be, so I will
investigate this and fix it if necessary. The file information problem
is most likely a bug, I'll have a look at it, as well as polishing up
the interface.
The :collect method in Agg.List is actually a method on functions, but
defined in Agg.List since it returns a list. I guess there could be
another similar method for tables, like :collect_table.
UNIQ expr sounds like an interesting idea, but it can be done in code as
(VAR t <- {}; EVERY t:insert(expr); t), just as (VAR l <- []; EVERY
l:put(expr); l) will emulate ALL expr. The main reason for ALL expr is
that directly appending to a list is a lot faster than the the overhead
of calling l:put(expr). ALL expr is effectively a more powerful form of
list comprehensions, already found in languages like Python. While the
time to call t:insert(expr), would be removed by a UNIQ expr, the call
to :"#" (to hash the value) and :"?" (to compare values) when inserting
into the table would still be present. If you think it would be useful
however, I'll implement it, it wouldn't be hard since I can reuse the
ALL code.
Btw, there's already COUNT expr, MIN expr, MAX expr, SUM expr and PROD
expr. With the exception of COUNT expr, the rest of these are not
trivial to write directly in Wrapl since they require special handling
of the first value generated by expr. However, they can be written using
the Std.Function.Iterator* functions.
^ relates to coexpressions (aka coroutines) which can be found in
Sys.Coexpr (they may not work in Windows at the moment). Among other
things, they were used to encapsulate a function call, allowing the
state of a function call to be passed as an object and queried for
additional values on demand. The Std.Function.Iterator* functions
provides a newer and simpler (and less powerful) interface for doing this.
Raja
Roman Mishin wrote:
> Raja,
>
> here I collected some things that I feel might be corrected in the
> documentation or implemented in the language.
> If you see some of them as inappropriate, skip them. They are grouped
> by Module:
>
> ================================================================================
> Libraries:Std:String (http://wrapl.sourceforge.net/doc/Std/String.html):
> ================================================================================
>
> A typo:
>
> :begins(a @ T, b @ T) : T
> Returns a if it begins with a, fails otherwise.
>
> should be
>
> Returns a if it begins with b, fails otherwise.
>
> --------------------------------------------------------------------------------
>
> There are undocumented (not mentioned but working) :reverse and :"+"
> methods.
>
> --------------------------------------------------------------------------------
>
> :"~="(_ @ T, _ @ T) should go up on the page, near to :"="(_ @ T, _ @ T)
>
> ================================================================================
> Libraries:Agg:List (http://wrapl.sourceforge.net/doc/Agg/List.html):
> ================================================================================
>
> :reverse(list @ T) : T
>
> The list itself becomes reversed. So "in place" might be added to the
> description (likewise for :sort method).
>
> ================================================================================
> Libraries:Agg:Table (http://wrapl.sourceforge.net/doc/Agg/Table.html)
> ================================================================================
>
> Since a Table with keys but no values can be thought of as a Set, the
> following might be added to the descriptions:
>
> :"*"(a @ T, b @ T) : T
> Intersection.
>
> :"+"(a @ T, b @ T) : T
> Union.
>
> :"-"(a @ T, b @ T) : T
> Difference.
>
> --------------------------------------------------------------------------------
>
> :insert(t @ T, key) : T
>
> should be
>
> :insert(t @ T, key, value) : T
>
> if value is omitted, NIL is supplied.
>
> --------------------------------------------------------------------------------
>
> Collect(func @ Std.Function.T) : T
> "... values returned by func as keys ..."
>
> should be
>
> Collect(func @ Std.Function.T, args) : T
> "... values returned by func(args) as keys ..."
>
> Otherwise it is not obvious from the description that the arguments
> can actually be passed to the func as Table.Collect(func, args); I
> didn't test this with multiple arguments, though.
>
> The same is true for the description of the List.Collect function.
>
> --------------------------------------------------------------------------------
>
> An observation (for the sake of consistency):
> There are Collect function and :collect method for Lists.
> There is only Collect function for Tables. No :collect method.
>
> --------------------------------------------------------------------------------
>
> Suggestion to create new expression:
>
> UNIQ expr
> Returns a set of the values produced by expr.
>
> Likewise ALL expr for creating a list.
>
> Rephrasing ALL's description on the Syntax page
> (http://wrapl.sourceforge.net/ref/syntax.html):
> Sets can also be constructed using UNIQ expressions: UNIQ expression
> will return a set consisting of the unique, sorted keys that are
> values produced by expression. If expression fails to produce any
> value, the result will be an empty table {}. For example: UNIQ " ac
> bed gfa de":chars \ NOT $ IN " \t\n\r" will give the set {"a", "b",
> "c", "d", "e", "f", "g"}. Another example: UNIQ [3, 2, 1, 4, 1,
> 4]:values will give the set {1, 2, 3, 4}.
>
> ================================================================================
> Libraries:Sys:FileSys (http://wrapl.sourceforge.net/doc/Sys/FileSys.html):
> ================================================================================
>
> TempFile() returns UNIX-like file name on Windows.
>
> Interactive Wrapl [1.9:1074]
> --> IMP Sys.FileSys;
> NIL
> --> FileSys.TempFile();
> "/tmp/t92c.0"
> -->
>
> --------------------------------------------------------------------------------
> The following is going on Linux (Ubuntu 10.04):
>
> Interactive Wrapl [1.9.1074:1074]
> --> IMP Sys.Environ;
> NIL
> --> Environ.GetCwd();
> "/home/roman/Downloads/Wrapl"
> --> IMP Sys.FileSys;
> NIL
> --> VAR d <- FileSys.ListDirInfo(".");
> <value>
> --> d:name;
> "wrapl-1.7-1041.tar.bz2"
> --> d:size;
> NIL
> --> d:type;
> 32768
> --> FileSys.FileSize("./wrapl-1.7-1041.tar.bz2");
> 2380542
> --> FileSys.FileType("./wrapl-1.7-1041.tar.bz2");
> 33261
> -->
>
> The result of FileSys.FileSize is what ls command gives but d:size is
> NIL.
> The results of d:type and FileSys.FileType are different.
>
> What is the bitmask of the types of the file? How to use (to decipher) it?
>
> :exists(info @ InfoT) and :time(info @ InfoT) methods would be handy too.
>
> ================================================================================
> From the Expressions page
> (http://wrapl.sourceforge.net/ref/expressions.html):
> "| expr" Generate all the values of expr repeatedly.
>
> From the Tutorial
> (http://wrapl.sourceforge.net/ref/tutorial/chapter3.html):
> The expression @ expr1 produces all the values produced by expr1 ad
> infinitum.
>
> I believe there should be "@ expr" instead of "| expr" on the
> Expressions page.
>
> --------------------------------------------------------------------------------
>
> NOT and IN might be mentioned on the Expressions page.
>
> --------------------------------------------------------------------------------
>
> I saw ^ (caret) somewhere in your code as a prefix to a variable.
> What does it perform? Could it be mentioned also?
>
> ================================================================================
> Using GTK+ (http://wrapl.sourceforge.net/samples/gtk.html):
>
> On Linux:
>
> Gtk1.wrapl
> ...
> dialog:Vbox:PackStartDefaults(label);
>
> method Vbox not found
>
> ================================================================================
> Tutorial (http://wrapl.sourceforge.net/ref/tutorial.html):
>
> Chapters 6, 7 and 8 lack navigational arrows.
>
> ================================================================================
> On the Download page (http://wrapl.sourceforge.net/download.html):
>
> A typo in the link to Lua (http://http//www.lua.org/).
>
> ================================================================================
> Website Search doesn't work currently:
> "Cannot connect to database, check if username, password and host are
> correct."
>
> Google has managed to index 9 pages only:
> http://www.google.ru/search?q=site:http://wrapl.sourceforge.net/
>
> Embedding Google Custom Search (http://www.google.com/cse/) could be
> an option.
>
> --
> Roman
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
|
|
From: Roman M. <rom...@gm...> - 2010-07-20 00:29:17
|
Raja, here I collected some things that I feel might be corrected in the documentation or implemented in the language. If you see some of them as inappropriate, skip them. They are grouped by Module: ================================================================================ Libraries:Std:String (http://wrapl.sourceforge.net/doc/Std/String.html): ================================================================================ A typo: :begins(a @ T, b @ T) : T Returns a if it begins with a, fails otherwise. should be Returns a if it begins with b, fails otherwise. -------------------------------------------------------------------------------- There are undocumented (not mentioned but working) :reverse and :"+" methods. -------------------------------------------------------------------------------- :"~="(_ @ T, _ @ T) should go up on the page, near to :"="(_ @ T, _ @ T) ================================================================================ Libraries:Agg:List (http://wrapl.sourceforge.net/doc/Agg/List.html): ================================================================================ :reverse(list @ T) : T The list itself becomes reversed. So "in place" might be added to the description (likewise for :sort method). ================================================================================ Libraries:Agg:Table (http://wrapl.sourceforge.net/doc/Agg/Table.html) ================================================================================ Since a Table with keys but no values can be thought of as a Set, the following might be added to the descriptions: :"*"(a @ T, b @ T) : T Intersection. :"+"(a @ T, b @ T) : T Union. :"-"(a @ T, b @ T) : T Difference. -------------------------------------------------------------------------------- :insert(t @ T, key) : T should be :insert(t @ T, key, value) : T if value is omitted, NIL is supplied. -------------------------------------------------------------------------------- Collect(func @ Std.Function.T) : T "... values returned by func as keys ..." should be Collect(func @ Std.Function.T, args) : T "... values returned by func(args) as keys ..." Otherwise it is not obvious from the description that the arguments can actually be passed to the func as Table.Collect(func, args); I didn't test this with multiple arguments, though. The same is true for the description of the List.Collect function. -------------------------------------------------------------------------------- An observation (for the sake of consistency): There are Collect function and :collect method for Lists. There is only Collect function for Tables. No :collect method. -------------------------------------------------------------------------------- Suggestion to create new expression: UNIQ expr Returns a set of the values produced by expr. Likewise ALL expr for creating a list. Rephrasing ALL's description on the Syntax page ( http://wrapl.sourceforge.net/ref/syntax.html): Sets can also be constructed using UNIQ expressions: UNIQ expression will return a set consisting of the unique, sorted keys that are values produced by expression. If expression fails to produce any value, the result will be an empty table {}. For example: UNIQ " ac bed gfa de":chars \ NOT $ IN " \t\n\r" will give the set {"a", "b", "c", "d", "e", "f", "g"}. Another example: UNIQ [3, 2, 1, 4, 1, 4]:values will give the set {1, 2, 3, 4}. ================================================================================ Libraries:Sys:FileSys (http://wrapl.sourceforge.net/doc/Sys/FileSys.html): ================================================================================ TempFile() returns UNIX-like file name on Windows. Interactive Wrapl [1.9:1074] --> IMP Sys.FileSys; NIL --> FileSys.TempFile(); "/tmp/t92c.0" --> -------------------------------------------------------------------------------- The following is going on Linux (Ubuntu 10.04): Interactive Wrapl [1.9.1074:1074] --> IMP Sys.Environ; NIL --> Environ.GetCwd(); "/home/roman/Downloads/Wrapl" --> IMP Sys.FileSys; NIL --> VAR d <- FileSys.ListDirInfo("."); <value> --> d:name; "wrapl-1.7-1041.tar.bz2" --> d:size; NIL --> d:type; 32768 --> FileSys.FileSize("./wrapl-1.7-1041.tar.bz2"); 2380542 --> FileSys.FileType("./wrapl-1.7-1041.tar.bz2"); 33261 --> The result of FileSys.FileSize is what ls command gives but d:size is NIL. The results of d:type and FileSys.FileType are different. What is the bitmask of the types of the file? How to use (to decipher) it? :exists(info @ InfoT) and :time(info @ InfoT) methods would be handy too. ================================================================================ >From the Expressions page (http://wrapl.sourceforge.net/ref/expressions.html ): "| expr" Generate all the values of expr repeatedly. >From the Tutorial (http://wrapl.sourceforge.net/ref/tutorial/chapter3.html): The expression @ expr1 produces all the values produced by expr1 ad infinitum. I believe there should be "@ expr" instead of "| expr" on the Expressions page. -------------------------------------------------------------------------------- NOT and IN might be mentioned on the Expressions page. -------------------------------------------------------------------------------- I saw ^ (caret) somewhere in your code as a prefix to a variable. What does it perform? Could it be mentioned also? ================================================================================ Using GTK+ (http://wrapl.sourceforge.net/samples/gtk.html): On Linux: Gtk1.wrapl ... dialog:Vbox:PackStartDefaults(label); method Vbox not found ================================================================================ Tutorial (http://wrapl.sourceforge.net/ref/tutorial.html): Chapters 6, 7 and 8 lack navigational arrows. ================================================================================ On the Download page (http://wrapl.sourceforge.net/download.html): A typo in the link to Lua (http://http//www.lua.org/). ================================================================================ Website Search doesn't work currently: "Cannot connect to database, check if username, password and host are correct." Google has managed to index 9 pages only: http://www.google.ru/search?q=site:http://wrapl.sourceforge.net/ Embedding Google Custom Search (http://www.google.com/cse/) could be an option. -- Roman |
|
From: Raja M. <raj...@gm...> - 2010-06-01 15:41:47
|
On 1 June 2010 12:26, Roman Mishin <rom...@gm...> wrote:
> > It is not necessary to use Out:write to show the results in Interactive
> > Wrapl, the results of a calculation are automatically displayed (and
> stored
> > in a variable called "_"). If you use Out:write(...) then the final
> result
> > is whatever is returned by Out:write(...) which is Out, which the
> > interactive interpreter resolves to be /usr/lib/IO/Terminal.Out.
>
> OK. Now I understand why it is outputted.
> I used Out:write(...) because otherwise the result with foreign
> characters is not informative:
> --> ALL s[5] | s[6] | s[7];
> ["\xAA", "\xA8", "\xA9"]
> But Out:write(...) somehow makes it right :)
>
Ah, the interactive interpreter tries to display the result as a string
that could appear in Wrapl code, so that UTF-8 characters in strings are
turned into escape sequences. I'll have a look about changing this
behaviour.
> > Currently Wrapl strings are only considered as arrays of single bytes
> >
> > --> "б":length;
> > 2
>
> On Windows in console I tried this:
> --> "б":length;
> 1
> --> "я":length;
> 1
> then created UTF-8 file with Out:write("б":length);
> C:\Home>riva utf.wrapl
> 2
>
>
That's interesting. Maybe you are using a different codepage and not UTF-8
in the console so that "б" is 1 byte in the console but 2 bytes in a UTF-8
file?
>
> > I think a set of UTF-8 aware methods or a subtype of String.T which is
> UTF-8
> > aware is probably necessary.
>
> I do not know of UTF internals and do not force you to make the
> decision based on the following text, however:
> About three month ago I studied GT.M (an open-source MUMPS
> implementation). They are using ICU library for the purpose to employ
> UTF-8. I saw the site http://icu-project.org/ . The library is quite
> extensive (and comprehensive). It rather big in size.
> Looking at GT.M: an interesting point is that during installation
> process GT.M allows to choose to install or not to install UTF
> support. GT.M distribution itself does not contain this library,
> rather it relies on ICU packages that are provided for the most Linux
> distributions. I saw it in the repositories of all distros I tried:
> ArchLinux, ZenLinux, Debian and even TinyCoreLinux.
>
>
Thanks, I will have a look at this.
>
> --
> Roman
>
Raja
|
|
From: Roman M. <rom...@gm...> - 2010-06-01 14:22:37
|
>
> On Windows in console I tried this:
>> --> "б":length;
>> 1
>> --> "я":length;
>> 1
>> then created UTF-8 file with Out:write("б":length);
>> C:\Home>riva utf.wrapl
>> 2
>>
>>
> That's interesting. Maybe you are using a different codepage and not UTF-8
> in the console so that "б" is 1 byte in the console but 2 bytes in a UTF-8
> file?
>
Yes, they are different. Probably, this is the reason the access by index
does work in console with Russian letters. In console I tried CP866
and CP1251. Both are 1 byte encodings.
--
Roman
|
|
From: Roman M. <rom...@gm...> - 2010-06-01 11:27:05
|
> It is not necessary to use Out:write to show the results in Interactive
> Wrapl, the results of a calculation are automatically displayed (and stored
> in a variable called "_"). If you use Out:write(...) then the final result
> is whatever is returned by Out:write(...) which is Out, which the
> interactive interpreter resolves to be /usr/lib/IO/Terminal.Out.
OK. Now I understand why it is outputted.
I used Out:write(...) because otherwise the result with foreign
characters is not informative:
--> ALL s[5] | s[6] | s[7];
["\xAA", "\xA8", "\xA9"]
But Out:write(...) somehow makes it right :)
> Currently Wrapl strings are only considered as arrays of single bytes
>
> --> "б":length;
> 2
On Windows in console I tried this:
--> "б":length;
1
--> "я":length;
1
then created UTF-8 file with Out:write("б":length);
C:\Home>riva utf.wrapl
2
> I think a set of UTF-8 aware methods or a subtype of String.T which is UTF-8
> aware is probably necessary.
I do not know of UTF internals and do not force you to make the
decision based on the following text, however:
About three month ago I studied GT.M (an open-source MUMPS
implementation). They are using ICU library for the purpose to employ
UTF-8. I saw the site http://icu-project.org/ . The library is quite
extensive (and comprehensive). It rather big in size.
Looking at GT.M: an interesting point is that during installation
process GT.M allows to choose to install or not to install UTF
support. GT.M distribution itself does not contain this library,
rather it relies on ICU packages that are provided for the most Linux
distributions. I saw it in the repositories of all distros I tried:
ArchLinux, ZenLinux, Debian and even TinyCoreLinux.
--
Roman
|
|
From: Raja M. <raj...@gm...> - 2010-06-01 07:52:28
|
Roman Mishin wrote:
> The message seems unreadable through SourceForge Mail Archive so I
> repost it as plain text.
>
> ---------- Forwarded message ----------
> From: Roman Mishin<rom...@gm...>
>
> I have tried new Wrapl's version (for Windows). On the whole, it all
> works well. All those methods I mentioned in previous letters are
> working.
> The following are the errors I found in the old Wrapl version. They
> remain in the new version also. Perhaps, I am making wrong invocation.
> -----------------------------------------
> File.Temp() function crashes the program:
> -----------------------------------------
> Interactive Wrapl [1.9:1074]
> --> IMP IO.File;
> NIL
> --> VAR f<- File.Temp();
> 4 [main] riva 408 exception::handle: Exception: STATUS_ACCESS_VIOLATION
> 467 [main] riva 408 open_stackdumpfile: Dumping stack trace to
> riva.exe.stackdump
> -----------------
> Here is the dump:
> -----------------
> Exception: STATUS_ACCESS_VIOLATION at eip=0080EACE
> eax=007AEB48 ebx=00000000 ecx=00817548 edx=00000000 esi=0080EAD5 edi=0022C918
> ebp=0022C8FC esp=0022C8FC program=C:\Wrapl\bin\riva.exe, pid 408, thread main
> cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
> Stack trace:
> Frame Function Args
> 0022C8FC 0080EACE (009C3810, 00000000, 00000000, 00000000)
> 00853F08 00000000 (1460FF10, 40000001, 00000000, 0096FF60)
> End of stack trace
>
After checking the source code, it seems that this function, and several
in the Sys.FileSys module also are not implemented yet in the windows
port. I will get started on implementing these and upload a new version
once they are done.
> -------------------------------
> Foreign character set mismatch:
> -------------------------------
> --> VAR S<- "Russian Language";
> "Russian Language"
> --> ALL S:any("s");
> [3, 4]
> --> VAR s<- "Русский Язык";
> "\x90\xE3\xE1\xE1\xAA\xA8\xA9 \x9F\xA7\xEB\xAA"
> --> Out:write('{s[3]}\n{s[4]}\n');
> с
> с
> /usr/lib/IO/Terminal.Out
> --> ALL s:any("с");
> [5, 6, 11]
> --> Out:write('{s[5]}\n{s[6]}\n{s[11]}\n');
> к
> и
> ы
> /usr/lib/IO/Terminal.Out
> --> Out:writes(ALL s:split(" "),"\n");
> [Русский, Язык]
> /usr/lib/IO/Terminal.Out
> --> Out:writes(ALL s:split("и"),"\n");
> [Русский Язык]
> /usr/lib/IO/Terminal.Out
> -->
>
> The file in attachment is the source code (UTF-8) that demonstrates
> the work of :map method with foreign characters. ltxt and utxt are
> unreadable in any encoding I tried. lower, upper and text variables
> are outputted as is and are readable.
> To summarize on Std.String library: those methods that access a string
> by index are working with foreign character sets (e.g. :"[]") but
> "modifiers" are not.
>
Currently Wrapl strings are only considered as arrays of single bytes
--> "б":length;
2
So they can be used to store and join UTF-8 text but some of the
string methods will not work correctly. Indexing should only index on
byte boundaries, it is surprising (and probably a coincidence) that it
seems to work here.
Methods that compare substrings will work, such as :find, although the
resulting index is in bytes and so "wrong" from a character point of
view. :map should work using the call
string:map(["а", "б", "в", "г", ...], ["А", "Б", "В", "Г", ...])
since it will replace each multi-byte substring.
I think a set of UTF-8 aware methods or a subtype of String.T which is
UTF-8 aware is probably necessary.
> Regarding Interactive Wrapl mode: is this necessary (helpful) to
> output module name after results are printed (i.e.
> /usr/lib/IO/Terminal.Out)?
>
>
It is not necessary to use Out:write to show the results in Interactive
Wrapl, the results of a calculation are automatically displayed (and
stored in a variable called "_"). If you use Out:write(...) then the
final result is whatever is returned by Out:write(...) which is Out,
which the interactive interpreter resolves to be /usr/lib/IO/Terminal.Out.
Btw, it seems that the line editing library I use for the Linux version
(tecla) does not support UTF-8 at all. I have been looking to replace it
for a while, so I will try to find one that is UTF-8 capable.
> --
> Roman
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
>
>
Again, thanks for the feedback.
Raja
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
|
|
From: Roman M. <rom...@gm...> - 2010-06-01 01:05:57
|
The message seems unreadable through SourceForge Mail Archive so I
repost it as plain text.
---------- Forwarded message ----------
From: Roman Mishin <rom...@gm...>
I have tried new Wrapl's version (for Windows). On the whole, it all
works well. All those methods I mentioned in previous letters are
working.
The following are the errors I found in the old Wrapl version. They
remain in the new version also. Perhaps, I am making wrong invocation.
-----------------------------------------
File.Temp() function crashes the program:
-----------------------------------------
Interactive Wrapl [1.9:1074]
--> IMP IO.File;
NIL
--> VAR f <- File.Temp();
4 [main] riva 408 exception::handle: Exception: STATUS_ACCESS_VIOLATION
467 [main] riva 408 open_stackdumpfile: Dumping stack trace to
riva.exe.stackdump
-----------------
Here is the dump:
-----------------
Exception: STATUS_ACCESS_VIOLATION at eip=0080EACE
eax=007AEB48 ebx=00000000 ecx=00817548 edx=00000000 esi=0080EAD5 edi=0022C918
ebp=0022C8FC esp=0022C8FC program=C:\Wrapl\bin\riva.exe, pid 408, thread main
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame Function Args
0022C8FC 0080EACE (009C3810, 00000000, 00000000, 00000000)
00853F08 00000000 (1460FF10, 40000001, 00000000, 0096FF60)
End of stack trace
-------------------------------
Foreign character set mismatch:
-------------------------------
--> VAR S <- "Russian Language";
"Russian Language"
--> ALL S:any("s");
[3, 4]
--> VAR s <- "Русский Язык";
"\x90\xE3\xE1\xE1\xAA\xA8\xA9 \x9F\xA7\xEB\xAA"
--> Out:write('{s[3]}\n{s[4]}\n');
с
с
/usr/lib/IO/Terminal.Out
--> ALL s:any("с");
[5, 6, 11]
--> Out:write('{s[5]}\n{s[6]}\n{s[11]}\n');
к
и
ы
/usr/lib/IO/Terminal.Out
--> Out:writes(ALL s:split(" "),"\n");
[Русский, Язык]
/usr/lib/IO/Terminal.Out
--> Out:writes(ALL s:split("и"),"\n");
[Русский Язык]
/usr/lib/IO/Terminal.Out
-->
The file in attachment is the source code (UTF-8) that demonstrates
the work of :map method with foreign characters. ltxt and utxt are
unreadable in any encoding I tried. lower, upper and text variables
are outputted as is and are readable.
To summarize on Std.String library: those methods that access a string
by index are working with foreign character sets (e.g. :"[]") but
"modifiers" are not.
Regarding Interactive Wrapl mode: is this necessary (helpful) to
output module name after results are printed (i.e.
/usr/lib/IO/Terminal.Out)?
--
Roman
|
|
From: Raja M. <raj...@gm...> - 2010-05-30 22:40:50
|
On 30 May 2010 10:37, Roman Mishin <rom...@gm...> wrote: > >>> VAR text <- mylist@String.T; >> > > Indeed. I have already used @ to convert an integer to a string in MOD > Bottles. I think I didn't get the very thing that the type itself is used as > an argument. > > You can also use >> >> mylist@(String.T, " ") >> > > I come up with such line: > Out:write(verse[2,0]@(String.T, "") + verse[1]); > I tried it on a Linux machine with the latest Wrapl version and it works. > > but I'm not very happy with this syntax and am still open to suggestions >> about changing it. >> > > Perhaps being not so intuitive at first sight, it seems OK to me. Knowing > that this syntax comes from a general rule of how to call a method, it seems > acceptable. > > The first thought on how to change it is to use something similar to: > mylist @ String.T VIA " "; analogous to :"[]=", and possibly using some > special character :"@~" (mylist @ String.T ~ " ";). This is from my > perspective, however. > Hmm, my idea for using the syntax I chose was that it should be possible to call @ with any number of parameters. I hadn't thought of using a method similar to :"[]=", but will consider it. > > > 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. >> > > Thank you. Most of the time I work on Windows. Recently, though, I set up a > Linux machine to experiment with. If you are interested, here is a little > bit of my experience with Wrapl installation on Linux: > > -- > I set up a fresh Debian-compatible distro - Linux Mint - on VirtualBox. > Then I installed both wrapl-1.7.1041.deb and wredit-1.7.1041.deb. Some > dependencies were installed by package manager. The whole installation went > without an issue. In the shell I got this: > > roman$ wrapl > Error: /usr/lib/libtermcap.so: undefined symbol: setupterm > Error: symbol setupterm not exported from libtermcap > Error relocating [82d7808] /usr/lib/riva/Util/Tecla.riva:93 > > As I found out this relates to the Wrapl interpreter only, not to riva. > "Hello World" scripts were working. > > I searched for "termcap Debian" and found this page > http://archive.debian.net/bo/admin/termcap-compat which explains > incompatibility between termcap and current Debian versions. So I installed > the package mentioned on the page. Yet, it didn't help. The error remained. > > The page also mentions libncurses, so in search for a solution the next > thing I did is installed libncurses5-dev package, since libncurses5 was > already in place. And this did help. Wrapl started right away. > > With not much experience, I think the only missing dependency is some > library in libncurses5-dev package. > Thank you for this useful feedback, I will be sure to add this dependency to the next release. > -- > > Going further, I want to ask how to read this descriptions in > Libraries:Agg:List: > > :"="(_ @ T, _ @ T, _ @ Agg.ObjectTable.T) > Does it compare two lists? [1, 2] = [1, 2]; I am getting "failure". > I think this method is only defined in the latest version, which I have just uploaded to the website, along with an updated Windows version (any feedback on this is appreciated). The Windows version is still missing a few modules, in particular all the Gtk based modules, and for now the Stat.* and Math.Random modules, since they haven't been ported to build correctly on Cygwin yet. > What is third argument? > Does underscore have special meaning in descriptions or it just denotes > "something"? > Yeah, _ is just used to denote "something", it is automatically generated by the documentation generator whenever actual descriptions are missing. It is also used for value paramters (=) since the parameter name doesn't really matter. > > > :"@"(_ @ T, _ = Std.String.T) > this seems similar to: > :"@"(list @ T, _ = Std.String.T, sep @ Std.String.T) : Std.String.T > but without separator and it does not define return type. It works: > The former returns a Std.String.T like the latter, but hasn't been documented yet. > --> VAR s <- mylist@String.T; > [one, two, three] > --> ? s; > C:\Wrapl\lib\Std\String.T > But I honestly wonder, is this practical after a conversion to have a > string formatted as list? > The list is actually converted into a string in this form, no formatting of the string is performed afterwards. This conversion is mainly intended for displaying the list. The second method for converting a list to a string (with a seperator) is probably more useful within an application. > > -- > Roman > Raja |
|
From: Roman M. <rom...@gm...> - 2010-05-30 09:37:26
|
> > >> VAR text <- mylist@String.T; > Indeed. I have already used @ to convert an integer to a string in MOD Bottles. I think I didn't get the very thing that the type itself is used as an argument. You can also use > > mylist@(String.T, " ") > I come up with such line: Out:write(verse[2,0]@(String.T, "") + verse[1]); I tried it on a Linux machine with the latest Wrapl version and it works. but I'm not very happy with this syntax and am still open to suggestions > about changing it. > Perhaps being not so intuitive at first sight, it seems OK to me. Knowing that this syntax comes from a general rule of how to call a method, it seems acceptable. The first thought on how to change it is to use something similar to: mylist @ String.T VIA " "; analogous to :"[]=", and possibly using some special character :"@~" (mylist @ String.T ~ " ";). This is from my perspective, however. 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. > Thank you. Most of the time I work on Windows. Recently, though, I set up a Linux machine to experiment with. If you are interested, here is a little bit of my experience with Wrapl installation on Linux: -- I set up a fresh Debian-compatible distro - Linux Mint - on VirtualBox. Then I installed both wrapl-1.7.1041.deb and wredit-1.7.1041.deb. Some dependencies were installed by package manager. The whole installation went without an issue. In the shell I got this: roman$ wrapl Error: /usr/lib/libtermcap.so: undefined symbol: setupterm Error: symbol setupterm not exported from libtermcap Error relocating [82d7808] /usr/lib/riva/Util/Tecla.riva:93 As I found out this relates to the Wrapl interpreter only, not to riva. "Hello World" scripts were working. I searched for "termcap Debian" and found this page http://archive.debian.net/bo/admin/termcap-compat which explains incompatibility between termcap and current Debian versions. So I installed the package mentioned on the page. Yet, it didn't help. The error remained. The page also mentions libncurses, so in search for a solution the next thing I did is installed libncurses5-dev package, since libncurses5 was already in place. And this did help. Wrapl started right away. With not much experience, I think the only missing dependency is some library in libncurses5-dev package. -- Going further, I want to ask how to read this descriptions in Libraries:Agg:List: :"="(_ @ T, _ @ T, _ @ Agg.ObjectTable.T) Does it compare two lists? [1, 2] = [1, 2]; I am getting "failure". What is third argument? Does underscore have special meaning in descriptions or it just denotes "something"? :"@"(_ @ T, _ = Std.String.T) this seems similar to: :"@"(list @ T, _ = Std.String.T, sep @ Std.String.T) : Std.String.T but without separator and it does not define return type. It works: --> VAR s <- mylist@String.T; [one, two, three] --> ? s; C:\Wrapl\lib\Std\String.T But I honestly wonder, is this practical after a conversion to have a string formatted as list? -- Roman |
|
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
>
>
|
|
From: Roman M. <rom...@gm...> - 2010-05-29 07:14:52
|
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;
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: @
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?
--
Roman
|
|
From: Raja M. <raj...@gm...> - 2010-05-24 10:30:45
|
Hi,
The problem is that, like all function calls, calling K(expr1, ..., exprN)
evaluates expr1, .., exprN first and then returns exprK. So both s <- "s"
and s <- "" are evaluated, in that order, but only if (2 > i) succeeds. So
for i = 9,8,..,2, neither s <- "s" or s <- "" are evaluated and s is "s"
from its initial value. Then when i = 1 or 0, both s <- "s" and s <- "" are
evaluated and s is "" afterwards.
Hope this clears things up,
Raja
On 24 May 2010 09:44, Roman Mishin <rom...@gm...> wrote:
> Hello.
>
> I am going through the Wrapl's tutorial and am trying to employ this
> function call: K(expr1, ..., exprN).
> I understand how it is intended to work and if K is an explicit integer, it
> works as expected, but if K is calculated, only expr1 is selected, no more.
>
> For example:
>
> MOD bottles;
>
> IMP IO.Terminal USE Out;
>
> VAR s <- "s"; DEF ob <- "of beer"; DEF otw <- "on the wall"; VAR i;
> EVERY i <- 9:to(0,-1) DO (
> ((2 > i) + 1)(s <- "s", s <- "");
> Out:write('{i} bottle{s} {ob} {otw}.\n');
> );
>
> END bottles.
>
> outputs:
> ...
> 2 bottles of beer on the wall.
> 1 bottle of beer on the wall.
> 0 bottle of beer on the wall.
>
> I want it to be:
> ...
> 2 bottles of beer on the wall.
> 1 bottle of beer on the wall.
> 0 bottles of beer on the wall.
>
> I am on Windows XP, Wrapl [1.1.5:864].
>
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
>
|
|
From: Roman M. <rom...@gm...> - 2010-05-24 08:44:52
|
Hello.
I am going through the Wrapl's tutorial and am trying to employ this
function call: K(expr1, ..., exprN).
I understand how it is intended to work and if K is an explicit integer, it
works as expected, but if K is calculated, only expr1 is selected, no more.
For example:
MOD bottles;
IMP IO.Terminal USE Out;
VAR s <- "s"; DEF ob <- "of beer"; DEF otw <- "on the wall"; VAR i;
EVERY i <- 9:to(0,-1) DO (
((2 > i) + 1)(s <- "s", s <- "");
Out:write('{i} bottle{s} {ob} {otw}.\n');
);
END bottles.
outputs:
...
2 bottles of beer on the wall.
1 bottle of beer on the wall.
0 bottle of beer on the wall.
I want it to be:
...
2 bottles of beer on the wall.
1 bottle of beer on the wall.
0 bottles of beer on the wall.
I am on Windows XP, Wrapl [1.1.5:864].
|
|
From: Raja M. <raj...@gm...> - 2008-09-13 12:59:25
|
Hi all, I've released version 1.1.5 of Wrapl in both source form and an Ubuntu package on the Wrapl website. I'll update the Windows version as soon as I can. The latest version fixes many bugs and adds: a) The Web.FastCGI module allowing Wrapl to be used for writing fastcgi applications. I've managed to write a small image gallery website with it and will add the source code to the samples page once I clean it up / add comments. b) The syntax `expr` (with backquotes) which evalutes expr once at compile time, instead of run time. c) Better support for rationals, especially with regard to exponents (e.g. 2 ^ -1 now returns 1/2). d) The Util.Random module, for random number routines. |
|
From: Raja M. <raj...@gm...> - 2008-08-19 16:07:28
|
I managed to build most of Wrapl on Windows under Cygwin (no Mysql or Gtk+ bindings) and have uploaded a binary package to the website. It's still incomplete, going through the source revealed several functions (mainly the thread and file system functions) with empty #ifdef WINDOWS ... #endif blocks. I will try to finish them when I get time, but at least the interactive interpreter works. The Linux package has been updated as well, the string concatenation code was improved to reduce memory consumption when constructing strings by repeated concatenation. Raja |
|
From: Raja M. <raj...@gm...> - 2008-08-17 17:41:01
|
I managed to build most of Wrapl on Windows under Cygwin (no Mysql or Gtk+ bindings) and have uploaded a binary package to the website. It's still incomplete, going through the source revealed several functions (mainly the thread and file system functions) with empty #ifdef WINDOWS ... #endif blocks. I will try to finish them when I get time, but at least the interactive interpreter works. The Linux package has been updated as well, the string concatenation code was improved to reduce memory consumption when constructing strings by repeated concatenation. Raja |
|
From: Raja M. <raj...@gm...> - 2008-08-16 08:42:55
|
The complete call is
db:exec(statement, function, userdata)
for each row of the result of executing statement, function(row, userdata)
is called, where row is a table of (column names, values).
To use prepared statements,
st <- db:prepare(statement)
returns a StatementT
st:bind(index, value)
binds value to the index-th parameter
st:step performs one step so you' d typically use
st <- db:prepare(statement);
REP (
WHEN st:step
IS Sqlite.DONE DO EXIT
IS Sqlite.ROW DO (
-- process row, using column_??? functions
)
IS Sqlite.ERROR DO -- handle error I guess
-- any other flags to handle
);
st:reset;
st:column_<type>(index)
returns the index-th column of the current result row from st as <type>,
where <type> is currently blob, double, int or text.
st:column_count
return the number of columns in the result row
st:column_name(index)
returns the name of index-th column
st:reset
resets the statement for another cycle
Although the interface works (the last time I checked, anyway), it does not
reclaim memory correctly. So over time there might be memory leakage. This
is on my TODO list.
Raja
2008/8/16 Jeremy Cowgar <je...@co...>
> How can I execute a query? I see exec, bind, column_text, etc... but not
> sure how to get at a StatementT to use step and column_text.
>
> MOD SqliteTest;
>
> IMP IO.Terminal USE Out;
> IMP DB.Sqlite;
>
> VAR db <- Sqlite.Open("testing.db");
>
> -- db:exec("SELECT * FROM abc", ?????);
>
> db:close();
>
> END SqliteTest.
>
>
> Thanks,
>
> Jeremy
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Wrapl-discussion mailing list
> Wra...@li...
> https://lists.sourceforge.net/lists/listinfo/wrapl-discussion
>
|