asked Nov 08 '11
This post is a wiki. Anyone with karma >75 is welcome to improve it.
We want to improve the Rascal libraries. Therefore we love to hear from you which library functions you are missing.
Thank you for helping us to make Rascal a great language.
answered Jan 13
This post is a wiki. Anyone with karma >75 is welcome to improve it.
Here is another function I would add to list library this time: (another overload of the slice function)
list[&T] slice(list[&T] lst, int begin)
where the result is lst from begin onwards.
Here are few minor features:
str objects, we need something like pop_back(n) which will remove
the n trailing characters of the string. n should obviously default to one.For map, we need a function like remove_key(k) which removes the key k (and its respective value), if any. The current syntax, as far as I could dig it, is just so clumsy: m - (k: v), with arbitrary value v of the range type of m. If no such value exists, one needs to coin a random one! Not in every context this makes sense.
We need good wildcard support! We currently lack support for many reasonable usecases. Here is a very simple and pervasive example: m - (k: _).
Working with SDF and Rascal, I found that I is much easier to design the grammar in SDF, because you can see the AST in a simple and compact form. Even if it is text, I could easily see that I forgot to put some follow restrictions or that some rules are ambiguous. I know that there are some functions that can allow you to see the parse tree in a compact way, but I couldn't make it to work, and I've seen that others had problems with it when they had ambiguities.
Also, can you have generic term composition and decomposition in the ParseTree and ADT?
Yes. I told Mark about this during the K workshop this summer and he told me that it could easily be done, and he actually started working on something like that, but didn't make it in this release. Maybe the next one.
Radu Mereuta (Nov 08 '11)editwhat happens if you call the implode function from ParseTree.rsc with #node as a type?
JurgenVinju (Nov 08 '11)editanswered Dec 20 '11
This post is a wiki. Anyone with karma >75 is welcome to improve it.
These functions were important for outputting Series 1&2.
Here is another very minor one: writelnFile which is the file counterpart of println.
What about writeFile? http://tutor.rascal-mpl.org/Courses/Rascal/Rascal.html#/Courses/Rascal/Libraries/IO/writeFile/writeFile.html
Dennisb (Dec 20 '11)editsimple one: a join function on a list[str] and set[str] with a string of choice as glue. Thanks to Arjen:
import Set;
public str joinstr(list[str] L, str glue) = ("" | size(it) > 0 ? "<it><glue><e>" : "<e>" | str e <- L);
public str joinstr(set[str] S, str glue) = joinstr(toList(S), glue);
How about http://tutor.rascal-mpl.org/Courses/Rascal/Libraries/Prelude/List/intercalate/intercalate.html intercalate(",", ["a", "b", "c"]); == "a,b,c"
PaulKlint (Jan 24)editanswered Jan 16
This post is a wiki. Anyone with karma >75 is welcome to improve it.
I cannot possibly help cursing Rascal for forcing me to write:
r.js = (r.js - (j: <j_name, false>)) + (j: <j_name, true>);
instead of
r.js[j][1] = true;
Full stop!!!
I wish I had also documented the error message that I got for it now works. But, it was something like "Internal Exception: ... not implemented yet" which made me sure that that's a problem with Rascal's current implementation.
Asked: Nov 08 '11
Seen: 90 times
Last updated: Jan 24
Copyright CWI, 2010-2012. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.