mirror of
https://github.com/kanaka/mal.git
synced 2024-09-19 09:38:28 +03:00
perl: When converting perl values to mal ones, convert undef to nil.
This commit is contained in:
parent
e88f9e1d67
commit
9530644d76
@ -7,7 +7,7 @@ use Exporter 'import';
|
||||
our @EXPORT_OK = qw( pl_to_mal );
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
|
||||
use types;
|
||||
use types qw($nil);
|
||||
|
||||
sub pl_to_mal {
|
||||
my($obj) = @_;
|
||||
@ -24,7 +24,9 @@ sub pl_to_mal {
|
||||
return Mal::HashMap->new($hsh)
|
||||
}
|
||||
default {
|
||||
if (looks_like_number($obj)) {
|
||||
if (!defined($obj)) {
|
||||
return $nil;
|
||||
} elsif (looks_like_number($obj)) {
|
||||
return Mal::Integer->new($obj);
|
||||
} else {
|
||||
return Mal::String->new($obj);
|
||||
|
@ -15,6 +15,9 @@
|
||||
(pl* "2+3")
|
||||
;=>5
|
||||
|
||||
(pl* "undef")
|
||||
;=>nil
|
||||
|
||||
;; Testing eval of print statement
|
||||
|
||||
(pl* "print 'hello\n';")
|
||||
|
Loading…
Reference in New Issue
Block a user