Make Python and C interpreters conform.
The Python one still checks number before type with get_n_items(). I can live with that for now.
This commit is contained in:
parent
eb38a7e817
commit
aacd9764fe
|
|
@ -845,7 +845,7 @@ joy(JoyListPtr stack, JoyListPtr expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Set quiet mode by "-q as only command line option. "*/
|
/* Set quiet mode by "-q" as only command line option. */
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
|
|
||||||
#define SHH(message) \
|
#define SHH(message) \
|
||||||
|
|
@ -876,7 +876,7 @@ main(int argc, char *argv[])
|
||||||
line = (char *)GC_malloc(1025);
|
line = (char *)GC_malloc(1025);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
SHH("\njoy? ")
|
SHH("joy? ")
|
||||||
status = gets_s(line, 1025);
|
status = gets_s(line, 1025);
|
||||||
if (NULL == status) {
|
if (NULL == status) {
|
||||||
/*
|
/*
|
||||||
|
|
@ -893,7 +893,7 @@ main(int argc, char *argv[])
|
||||||
TODO: "use feof(3) and ferror(3)"...
|
TODO: "use feof(3) and ferror(3)"...
|
||||||
|
|
||||||
*/
|
*/
|
||||||
SHH("bye\n")
|
SHH("\n")
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = stack;
|
s = stack;
|
||||||
|
|
|
||||||
|
|
@ -1311,7 +1311,7 @@ def isnt_int(i):
|
||||||
(Booleans are not integers in Joy.)
|
(Booleans are not integers in Joy.)
|
||||||
'''
|
'''
|
||||||
if not isinstance(i, int) or isinstance(i, bool):
|
if not isinstance(i, int) or isinstance(i, bool):
|
||||||
raise NotAnIntError(f'Not an integer: {_s(i)}')
|
raise NotAnIntError('Not an integer.')
|
||||||
return i
|
return i
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1320,7 +1320,7 @@ def isnt_bool(b):
|
||||||
Raise NotABoolError if b isn't a Boolean.
|
Raise NotABoolError if b isn't a Boolean.
|
||||||
'''
|
'''
|
||||||
if not isinstance(b, bool):
|
if not isinstance(b, bool):
|
||||||
raise NotABoolError(f'Not a Boolean value: {_s(b)}')
|
raise NotABoolError('Not a Boolean value.')
|
||||||
return b
|
return b
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1329,7 +1329,7 @@ def isnt_stack(el):
|
||||||
Raise NotAListError if el isn't a stack/quote/list.
|
Raise NotAListError if el isn't a stack/quote/list.
|
||||||
'''
|
'''
|
||||||
if not isinstance(el, tuple):
|
if not isinstance(el, tuple):
|
||||||
raise NotAListError(f'Not a list: {_s(el)}')
|
raise NotAListError('Not a list.')
|
||||||
return el
|
return el
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2770,4 +2770,4 @@ if __name__ == '__main__':
|
||||||
## jcode = '3 dup [dup mul] times'
|
## jcode = '3 dup [dup mul] times'
|
||||||
## jcode = '0 [1 2 3] [add] step'
|
## jcode = '0 [1 2 3] [add] step'
|
||||||
## stack, _ = run(jcode, (), dictionary)
|
## stack, _ = run(jcode, (), dictionary)
|
||||||
print(stack_to_string(stack), '•')
|
##print(stack_to_string(stack))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue