1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-17 16:47:22 +03:00

perl: When converting perl values to mal ones, convert undef to nil.

This commit is contained in:
Ben Harris 2019-07-27 12:40:04 +01:00
parent e88f9e1d67
commit 9530644d76
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

@ -15,6 +15,9 @@
(pl* "2+3")
;=>5
(pl* "undef")
;=>nil
;; Testing eval of print statement
(pl* "print 'hello\n';")