Skip to content

Commit

Permalink
- Reduced the number of built-in keywords. say, print, println,…
Browse files Browse the repository at this point in the history
… `require` and `frequire` are no longer hardcoded inside the parser; they are now parsed as prefix-methods.

Example:
	say "hello";	# really means: "hello".say;

By not being a special keyword, it can be used as a variable.

Example:
	var say = 42;
	"a" say;	# means: "a".say;
	say say;	# means: say.say;

- Simplified the interal object system. The conversion methods are no longer avaiable to all objects. For example, a Block can no longer be converted into a Number or a String by using the `to_s` or `to_i` methods.

Example:
	{}.to_s;	# can't find method `to_s` for Block object

- Simplified the conversion system. The camelCase methods are no longer avaiable for conversion.

Example:
	"123".toNum;	# error -- use `.to_num` instead

- Removed the built-in `Fcntl` object. Its methods are now avaiable as: File::*

Example:
	File::O_RDONLY;	# equivalent with the old code: `Fcntl.O_RDONLY`

- Renamed the module `Module::Caller` into `Module::OO` to reflect better its job.
- Functions and method calls on Perl modules are now fatal error when a method/function doesn't exists. (UNIVERSAL::AUTOLOAD is now hidden away at each call)
- Other minor tweaks and performance improvements.
  • Loading branch information
trizen committed Jul 22, 2015
1 parent 354e22e commit 48c1f1f
Show file tree
Hide file tree
Showing 54 changed files with 411 additions and 616 deletions.
6 changes: 1 addition & 5 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ lib/Sidef/Eval/Eval.pod
lib/Sidef/Exec.pm
lib/Sidef/Math/Math.pm
lib/Sidef/Math/Math.pod
lib/Sidef/Module/Caller.pm
lib/Sidef/Module/Func.pm
lib/Sidef/Module/Require.pm
lib/Sidef/Module/Require.pod
lib/Sidef/Module/OO.pm
lib/Sidef/Object/Object.pm
lib/Sidef/Object/Object.pod
lib/Sidef/Object/Unary.pm
Expand Down Expand Up @@ -87,8 +85,6 @@ lib/Sidef/Types/Glob/Dir.pm
lib/Sidef/Types/Glob/Dir.pod
lib/Sidef/Types/Glob/DirHandle.pm
lib/Sidef/Types/Glob/DirHandle.pod
lib/Sidef/Types/Glob/Fcntl.pm
lib/Sidef/Types/Glob/Fcntl.pod
lib/Sidef/Types/Glob/File.pm
lib/Sidef/Types/Glob/File.pod
lib/Sidef/Types/Glob/FileHandle.pm
Expand Down
10 changes: 2 additions & 8 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,11 @@
"Sidef::Math::Math" : {
"file" : "lib/Sidef/Math/Math.pm"
},
"Sidef::Module::Caller" : {
"file" : "lib/Sidef/Module/Caller.pm"
},
"Sidef::Module::Func" : {
"file" : "lib/Sidef/Module/Func.pm"
},
"Sidef::Module::Require" : {
"file" : "lib/Sidef/Module/Require.pm"
"Sidef::Module::OO" : {
"file" : "lib/Sidef/Module/OO.pm"
},
"Sidef::Object::Object" : {
"file" : "lib/Sidef/Object/Object.pm"
Expand Down Expand Up @@ -206,9 +203,6 @@
"Sidef::Types::Glob::DirHandle" : {
"file" : "lib/Sidef/Types/Glob/DirHandle.pm"
},
"Sidef::Types::Glob::Fcntl" : {
"file" : "lib/Sidef/Types/Glob/Fcntl.pm"
},
"Sidef::Types::Glob::File" : {
"file" : "lib/Sidef/Types/Glob/File.pm"
},
Expand Down
8 changes: 2 additions & 6 deletions META.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ provides:
file: lib/Sidef/Exec.pm
Sidef::Math::Math:
file: lib/Sidef/Math/Math.pm
Sidef::Module::Caller:
file: lib/Sidef/Module/Caller.pm
Sidef::Module::Func:
file: lib/Sidef/Module/Func.pm
Sidef::Module::Require:
file: lib/Sidef/Module/Require.pm
Sidef::Module::OO:
file: lib/Sidef/Module/OO.pm
Sidef::Object::Object:
file: lib/Sidef/Object/Object.pm
Sidef::Object::Unary:
Expand Down Expand Up @@ -116,8 +114,6 @@ provides:
file: lib/Sidef/Types/Glob/Dir.pm
Sidef::Types::Glob::DirHandle:
file: lib/Sidef/Types/Glob/DirHandle.pm
Sidef::Types::Glob::Fcntl:
file: lib/Sidef/Types/Glob/Fcntl.pm
Sidef::Types::Glob::File:
file: lib/Sidef/Types/Glob/File.pm
Sidef::Types::Glob::FileHandle:
Expand Down
42 changes: 4 additions & 38 deletions lib/Sidef/Convert/Convert.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package Sidef::Convert::Convert {
# This module is used only as parent!

use 5.014;
our @ISA = qw(Sidef);

use overload;

sub to_s {
Expand All @@ -15,9 +13,7 @@ package Sidef::Convert::Convert {
: $self;
}

*toStr = \&to_s;
*to_str = \&to_s;
*toString = \&to_s;
*to_string = \&to_s;

sub to_obj {
Expand All @@ -33,108 +29,78 @@ package Sidef::Convert::Convert {
}

*to_integer = \&to_i;
*toInt = \&to_i;
*to_int = \&to_i;
*toInteger = \&to_i;

sub to_rat {
Sidef::Types::Number::Number->new_rat($_[0]->get_value);
}

*to_rational = \&to_rat;
*to_r = \&to_rat;
*toRat = \&to_rat;
*toRational = \&to_rat;

sub to_complex {
Sidef::Types::Number::Complex->new($_[0]->get_value);
}

*toComplex = \&to_complex;
*to_c = \&to_complex;
*to_c = \&to_complex;

sub to_num {
Sidef::Types::Number::Number->new($_[0]->get_value);
}

*toNum = \&to_num;
*to_number = \&to_num;
*toNumber = \&to_num;

sub to_float {
Sidef::Types::Number::Number->new_float($_[0]->get_value);
}

*to_f = \&to_float;
*toFloat = \&to_float;
*to_f = \&to_float;

sub to_file {
Sidef::Types::Glob::File->new($_[0]->get_value);
}

*toFile = \&to_file;

sub to_dir {
Sidef::Types::Glob::Dir->new($_[0]->get_value);
}

*toDir = \&to_dir;

sub to_bool {
Sidef::Types::Bool::Bool->new($_[0]->get_value);
}

*toBool = \&to_bool;

sub to_byte {
Sidef::Types::Byte::Byte->new(CORE::ord($_[0]->get_value));
}

*toByte = \&to_byte;

sub to_char {
Sidef::Types::Char::Char->call($_[0]->get_value);
}

*toChar = \&to_char;

sub to_regex {
Sidef::Types::Regex::Regex->new($_[0]->get_value);
}

*toRe = \&to_regex;
*to_re = \&to_regex;
*toRegex = \&to_regex;
*to_re = \&to_regex;

sub to_bytes {
Sidef::Types::Byte::Bytes->call($_[0]->get_value);
}

*toBytes = \&to_bytes;

sub to_chars {
Sidef::Types::Char::Chars->call($_[0]->get_value);
}

*toChars = \&to_chars;

sub to_array {
Sidef::Types::Array::Array->new($_[0]);
}

*toArray = \&to_array;

sub to_caller {
Sidef::Module::Caller->__NEW__(module => $_[0]->get_value);
Sidef::Module::OO->__NEW__(module => $_[0]->get_value);
}

*toCaller = \&to_caller;

sub to_fcaller {
Sidef::Module::Func->__NEW__(module => $_[0]->get_value);
}

*toFcaller = \&to_fcaller;
};

1
Loading

0 comments on commit 48c1f1f

Please sign in to comment.