[pure-lang-svn] SF.net SVN: pure-lang:[639] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-27 20:35:38
|
Revision: 639 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=639&view=rev Author: agraef Date: 2008-08-27 20:35:47 +0000 (Wed, 27 Aug 2008) Log Message: ----------- Keep the namespace clean. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lib/math.pure pure/trunk/lib/primitives.pure pure/trunk/lib/strings.pure pure/trunk/lib/system.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-08-27 19:33:15 UTC (rev 638) +++ pure/trunk/ChangeLog 2008-08-27 20:35:47 UTC (rev 639) @@ -1,5 +1,7 @@ 2008-08-27 Albert Graef <Dr....@t-...> + * lib/: Clean up the public namespace. + * lexer.ll: Added limited support for unicode symbols. These can now be declared as operator or nullary symbols. Modified: pure/trunk/lib/math.pure =================================================================== --- pure/trunk/lib/math.pure 2008-08-27 19:33:15 UTC (rev 638) +++ pure/trunk/lib/math.pure 2008-08-27 20:35:47 UTC (rev 639) @@ -32,6 +32,7 @@ /* Exponential function and logarithms. */ +private c_log; extern double exp(double), double log(double) = c_log; ln x::double = c_log x; @@ -71,12 +72,9 @@ /* Hyperbolic functions. */ extern double sinh(double), double cosh(double), double tanh(double); -extern double __asinh(double), double __acosh(double), double __atanh(double); +extern double __asinh(double) = asinh, double __acosh(double) = acosh, + double __atanh(double) = atanh; -asinh x::double = __asinh x; -acosh x::double = __acosh x; -atanh x::double = __atanh x; - sinh x::int | sinh x::bigint = sinh (double x); cosh x::int | cosh x::bigint = cosh (double x); tanh x::int | tanh x::bigint = tanh (double x); @@ -376,8 +374,6 @@ /* Conversions. */ -extern expr* pure_rational(double); - rational x@(_%_) = x; rational x::int | rational x::bigint = x%1; @@ -385,6 +381,8 @@ /* The conversion from double doesn't do any rounding, so it is guaranteed that converting the resulting rational back to double reconstructs the original value. */ +private pure_rational; +extern expr* pure_rational(double); rational x::double = n%d when n,d = pure_rational x end; rational (x+:y) = rational x +: rational y; Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-08-27 19:33:15 UTC (rev 638) +++ pure/trunk/lib/primitives.pure 2008-08-27 20:35:47 UTC (rev 639) @@ -77,6 +77,7 @@ /* Conversions between the different numeric and pointer types. */ +private pure_intval pure_dblval pure_bigintval pure_pointerval; extern expr* pure_intval(expr*), expr* pure_dblval(expr*), expr* pure_bigintval(expr*), expr* pure_pointerval(expr*); @@ -221,6 +222,8 @@ /* Bigint arithmetic. */ +private bigint_neg bigint_not bigint_add bigint_sub bigint_mul bigint_div + bigint_mod bigint_shl bigint_shr bigint_and bigint_or bigint_cmp; extern expr* bigint_neg(void*); extern expr* bigint_not(void*); extern expr* bigint_add(void*, void*); @@ -322,6 +325,7 @@ /* The gcd and lcm functions from the GMP library. These return a bigint if at least one of the arguments is a bigint, a machine int otherwise. */ +private bigint_gcd bigint_lcm; extern expr* bigint_gcd(void*, void*); extern expr* bigint_lcm(void*, void*); @@ -340,6 +344,7 @@ always a bigint. Note that y must always be nonnegative here, but see math.pure which deals with the case y<0 using rational numbers. */ +private bigint_pow; extern expr* bigint_pow(void*, int); pow x::int y::int = bigint_pow (bigint x) y if y>=0; @@ -352,6 +357,7 @@ /* The ^ operator. Computes inexact powers for any combination of int, bigint and double operands. The result is always a double. */ +private c_pow; extern double pow(double, double) = c_pow; x::double^y::double = c_pow x y; @@ -382,6 +388,8 @@ /* Direct memory accesses. Use with care ... or else! */ +private pointer_get_byte pointer_get_int pointer_get_double + pointer_get_string pointer_get_pointer; extern int pointer_get_byte(void *ptr); extern int pointer_get_int(void *ptr); extern double pointer_get_double(void *ptr); @@ -394,6 +402,8 @@ get_string x::pointer = pointer_get_string x; get_pointer x::pointer = pointer_get_pointer x; +private pointer_put_byte pointer_put_int pointer_put_double + pointer_put_string pointer_put_pointer; extern void pointer_put_byte(void *ptr, int x); // IMPURE! extern void pointer_put_int(void *ptr, int x); // IMPURE! extern void pointer_put_double(void *ptr, double x); // IMPURE! Modified: pure/trunk/lib/strings.pure =================================================================== --- pure/trunk/lib/strings.pure 2008-08-27 19:33:15 UTC (rev 638) +++ pure/trunk/lib/strings.pure 2008-08-27 20:35:47 UTC (rev 639) @@ -28,6 +28,7 @@ was encountered during the most recent invokation of eval(). In that case each reported error message is terminated with a newline character. */ +private pure_str; extern void* str(expr*) = pure_str; extern expr* eval(char*); // IMPURE! extern char* lasterr(); @@ -36,6 +37,7 @@ /* Convert between Unicode character codes and single character strings. */ +private string_chr string_ord; extern expr* string_chr(int); extern expr* string_ord(void*); @@ -51,6 +53,7 @@ to be malloc'ed). The _cstring routines also convert from the system encoding. */ +private pure_string pure_cstring pure_string_dup pure_cstring_dup; extern expr* pure_string(void* s); extern expr* pure_cstring(void* s); extern expr* pure_string_dup(void* s); @@ -68,6 +71,7 @@ char* (employing pointer arithmetic etc.; the usual caveats apply), and has to be freed explicitly by the caller when no longer needed. */ +private pure_byte_string pure_byte_cstring; extern expr* pure_byte_string(void *s); extern expr* pure_byte_cstring(void *s); @@ -86,6 +90,7 @@ string takes quadratic time; as a remedy, we also offer a linear-time operation to determine the list of all characters of a string in one go. */ +private string_null string_size string_concat string_char_at string_chars; extern bool string_null(void*); extern int string_size(void*); extern expr* string_concat(void*, void*); @@ -100,6 +105,7 @@ /* Lexicographic string comparison. */ +private strcmp; extern int strcmp(void*, void*); x::string<y::string = strcmp x y < 0; @@ -111,6 +117,7 @@ /* Compute and find substrings of a string. */ +private string_substr string_index; extern expr* string_substr(void*, int, int); extern int string_index(void*, void*); @@ -122,6 +129,7 @@ /* Concatenate a list of strings. */ +private string_concat_list; extern expr* string_concat_list(expr*); strcat xs = string_concat_list xs if listp xs && all stringp xs; Modified: pure/trunk/lib/system.pure =================================================================== --- pure/trunk/lib/system.pure 2008-08-27 19:33:15 UTC (rev 638) +++ pure/trunk/lib/system.pure 2008-08-27 20:35:47 UTC (rev 639) @@ -34,6 +34,7 @@ regex functions. After loading this module, see list -v for a list of these. */ +private pure_sys_vars; extern void pure_sys_vars(); pure_sys_vars; /* errno and friends. This value and the related routines are indispensable to @@ -41,12 +42,9 @@ by its very nature, errno is a fairly volatile value, don't expect it to survive a return to the command line in interactive sessions. */ -extern int pure_errno(), void pure_set_errno(int); +extern int pure_errno() = errno, void pure_set_errno(int) = set_errno; extern void perror(char*), char* strerror(int); -errno = pure_errno; -set_errno val::int = pure_set_errno val; - /* Signal handling. The action parameter of 'trap' can be one of the predefined integer values SIG_TRAP, SIG_IGN and SIG_DFL. SIG_TRAP causes the given signal to be handled by mapping it to a Pure exception of the @@ -125,6 +123,7 @@ routines are actually overridden with more convenient Pure wrappers below. */ +private c_fgets c_gets; extern FILE* fopen(char* name, char* mode); extern FILE* popen(char* cmd, char* mode); extern int fflush(FILE* fp), int fclose(FILE* fp), int pclose(FILE* fp); @@ -176,12 +175,16 @@ case of an abnormal condition in the wrapper function (error in format string, argument mismatch), they will throw an exception. */ +private pure_fprintf pure_fprintf_int pure_fprintf_double + pure_fprintf_string pure_fprintf_pointer; extern int pure_fprintf(FILE *fp, char *format); extern int pure_fprintf_int(FILE *fp, char *format, int x); extern int pure_fprintf_double(FILE *fp, char *format, double x); extern int pure_fprintf_string(FILE *fp, char *format, char *x); extern int pure_fprintf_pointer(FILE *fp, char *format, void *x); +private printf_split_format printf_format_spec printf_format_str; + printf format::string args = fprintf stdout format args; fprintf fp::pointer format::string args = count when @@ -237,6 +240,8 @@ as with printf/fprintf. The implementation actually uses snprintf for safety, a suitable output buffer is provided automatically. */ +private pure_snprintf pure_snprintf_int pure_snprintf_double + pure_snprintf_string pure_snprintf_pointer; extern int pure_snprintf(void *buf, int, char *format); extern int pure_snprintf_int(void *buf, int, char *format, int x); extern int pure_snprintf_double(void *buf, int, char *format, double x); @@ -292,12 +297,16 @@ "assignment suppression" flag "*" is understood; the corresponding items will not be returned. */ +private pure_fscanf pure_fscanf_int pure_fscanf_double + pure_fscanf_string pure_fscanf_pointer; extern int pure_fscanf(FILE *fp, char *format); extern int pure_fscanf_int(FILE *fp, char *format, int *x); extern int pure_fscanf_double(FILE *fp, char *format, double *x); extern int pure_fscanf_string(FILE *fp, char *format, void *x); extern int pure_fscanf_pointer(FILE *fp, char *format, void **x); +private scanf_split_format scanf_format_spec scanf_format_str; + scanf format::string = fscanf stdin format; fscanf fp::pointer format::string = tuple $ reverse ret when @@ -385,6 +394,8 @@ /* sscanf: This works exactly like fscanf, but input comes from a string (first argument) rather than a file. */ +private pure_sscanf pure_sscanf_int pure_sscanf_double + pure_sscanf_string pure_sscanf_pointer; extern int pure_sscanf(char *buf, char *format); extern int pure_sscanf_int(char *buf, char *format, int *x); extern int pure_sscanf_double(char *buf, char *format, double *x); @@ -455,6 +466,7 @@ return value.) We also provide readline's companion, the add_history function, which you need to add strings to readline's history. */ +private c_readline; extern void* readline(char* prompt) = c_readline; extern void add_history(char* s); @@ -472,6 +484,7 @@ extension to POSIX, Pure also provides the constant GLOB_SIZE which indicates the buffer size required for glob's globptr argument. */ +private c_fnmatch c_glob globfree globlist; extern int fnmatch(char* pat, char* s, int flags) = c_fnmatch; extern int glob(char* pat, int flags, void* errfunc, void* globptr) = c_glob; extern void globfree(void* globptr); @@ -491,6 +504,7 @@ difficult calling sequence, hence we provide a couple of high-level wrapper functions for use in Pure programs below. */ +private regcomp regexec regerror regfree regmatches reglist; extern int regcomp(void* regptr, char* pat, int cflags); extern int regexec(void* regptr, char* s, int n, void* matches, int eflags); extern int regerror(int errcode, void* regptr, void* buf, int size); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |