Some proposed improvements to the GP language
1) functional programming-like features:
1.1) [DONE] Comprehension:
[a(x) | x<-b, c(x)] for apply(a, select(c,b))
1.2) [DONE] Comprehension (shortcut)
[x<-b, c(x)] for select(c,b))
1.3) fun^k for x->fun( ... fun(fun(x)) ... ) (k times)
f @ g for composition
2) Range
2.1) [DONE]
F[2..4] = [F[2],F[3],F[4]]
F[^2] = [F[1], F[3] ... ]
F[[1,2,4]] = [F[1],F[2],F[4]]
v = [1,2,4]; F[v] = [F[1],F[2],F[4]]
For t_MAT:
F[, 2..4] = matrix with columns F[,2]...F[,4]
F[2..4,] = matrix with rows F[2, ]...F[4,]
F[2..4, 3..4] = 3 x 2 matrix F[2,3], F[2,4]
F[3,3], F[3,4]
F[4,3], F[4,4]
2.2) F[2..] = F[2..#F]. Is this a good idea ?
2.3) [DONE] Range: [1..4] = [1,2,3,4]
2.4) Ranges: potential (= unexpanded), not actual [= vector(4,i,i)]
2.5) [DONE] Simultaneous assignment
[a,b] = [1, 2] -> a=1; b=2;
while(b, [a,b] = [b, a%b])
[a,b] = w: if #w > # of variables: discard
if #w < # of variables: error
3) Precision:
3.1) myprec(x): set realprecision to precision(x) in the current block
3.2) Allow to handle precision in bits instead of digits.
default(realbitprecision, ...)
bitprecision(x, ...)
\p -> \pb ?
4) [DONE] Debugging features:
4.1) [DONE] breakpoint
4.2) [DONE] move up / down the stack frame.
4.3) [DONE] access to error information in the breakloop. E = dbg_err() ?
4.4) [DONE: dbg_x] access to \x in the breakloop. dbg_GEN(x, nb = -1) ?
5) Support for parallel computation.
5.1) Support for OpenMPI and POSIX threads.
5.2) parallel evaluation of vectors or loops.
6) Efficiency problems
6.1) my(v=v); for (i=1,10^5, f(v))
6.2) [DONE] return(x) vs. x; return(x) : clone + copy. Remove clone ?
7) Iterators
7.1) [DONE] forprime() general iterator: up to primelimit^2 (sieve),
then via n = nextprime(n+1)
7.2) forfactored(n = a,b, ...) : for(k = a,b, n = [k, factor(k)]; ...)
7.3) forprimefactors()
7.4) buhler gross
8) Misc.
8.1) rename cmp -> cmp_universal / cmp_all ? Make cmp refer to gcmp()
operator
8.2) t_FILE for read/write, t_BITS (F2c),
8.3) [DONE]remove support for vector / matrices in arithmetic functions
8.4) (8.3 prerequisite) [ N, factor(N) ] allowed as argument to all
arithmetic functions
8.5) readstr(): returns the vector of lines in a file as t_STR
better name for externstr / readstr ?
8.6) semi-permanent structs: allow GENs associated to a mathematical
structure (ell, bnf) to contain a pointer to the struct instead
of a deep copy. Would allow new types such as
"element of a number field K" or "point on the curve E"
8.7) namespace issues: allow private functions in a code module.
Currently my(f); f(x) = ... in file foo does not work since f has
global scope, not restricted to "foo"
8.8) variable ordering: give a way to create a variable whose priority is
greater (resp. lower) than any other then existing variable.
8.9) no longer filter out spaces from user input