Skip to content

Commit

Permalink
- Added support for multiple dispatch.
Browse files Browse the repository at this point in the history
Much better and faster than ever before!!!

- Major change: all function/method parameters are required by default, unless a default value is provided.

Example:
	func foo(a, b) {

	}
	foo(42)			# error: foo() requires two arguments

- Optimized the prefix and postfix `++` and `--` operators.
- Overall performance improvements.
  • Loading branch information
trizen committed Nov 30, 2015
1 parent 8ab97cf commit ab914f8
Show file tree
Hide file tree
Showing 26 changed files with 484 additions and 179 deletions.
5 changes: 4 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ lib/Sidef/Types/Regex/Regex.pod
lib/Sidef/Types/String/String.pm
lib/Sidef/Types/String/String.pod
lib/Sidef/Variable/ClassAttr.pm
lib/Sidef/Variable/ClassAttr.pod
lib/Sidef/Variable/ClassInit.pm
lib/Sidef/Variable/ClassInit.pod
lib/Sidef/Variable/Const.pm
Expand Down Expand Up @@ -266,6 +267,7 @@ scripts/langton_s_ant_2.sf
scripts/linear_congruential_generator.sf
scripts/mandelbrot_set.sf
scripts/matrix_multiplication.sf
scripts/multiple_dispatch.sf
scripts/mutual_recursion.sf
scripts/nth_root.sf
scripts/permutations_iter.sf
Expand Down Expand Up @@ -368,6 +370,7 @@ scripts/RosettaCode/convert_decimal_number_to_rational.sf
scripts/RosettaCode/copy_a_string.sf
scripts/RosettaCode/count_in_factors.sf
scripts/RosettaCode/count_occurrences_of_a_substring.sf
scripts/RosettaCode/create_an_html_table.sf
scripts/RosettaCode/date_format.sf
scripts/RosettaCode/delete_a_file.sf
scripts/RosettaCode/determine_if_a_string_is_numeric.sf
Expand All @@ -381,7 +384,6 @@ scripts/RosettaCode/enumerations.sf
scripts/RosettaCode/enumerations_1.sf
scripts/RosettaCode/equilibrium_index.sf
scripts/RosettaCode/euler_method.sf
scripts/RosettaCode/evaluate_binomial_coefficients.sf
scripts/RosettaCode/factorial.sf
scripts/RosettaCode/fibonacci_n-step_number_sequence.sf
scripts/RosettaCode/fibonacci_sequence.sf
Expand Down Expand Up @@ -822,6 +824,7 @@ t/00-load.t
t/01-parser.t
t/manifest.t
t/pod.t
TODO
utils/auto_perltidy.sh
utils/bak_cleaner.sh
utils/Concepts/sidef_concept.jl
Expand Down
19 changes: 19 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TODO list for Sidef

General:
* improve the OO system
* reduce the usage of the `overload` pragma

Method/function parameters:
* add the `where` trait:

func foo(a where { _ > 0 }) { # works only with positive numbers
say a
}
foo(42) # ok
foo(-1) # must be an error

Method/functions:
* implement the `is export` trait for methods (maybe)
* improve the user-defined auto-conversion methods (such as: to_s)
`- maybe, rename `to_s` to `to_str`?
8 changes: 8 additions & 0 deletions lib/Sidef.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ package Sidef {
sub new {
bless {}, __PACKAGE__;
}

sub unpack_args {
map {
ref($_) && eval { $_->can('to_s') }
? $_->to_s
: $_
} @_;
}
};

#
Expand Down
2 changes: 2 additions & 0 deletions lib/Sidef/Convert/Convert.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ package Sidef::Convert::Convert {
Sidef::Types::Bool::Bool->new($_[0]->get_value);
}

*to_b = \&to_bool;

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

0 comments on commit ab914f8

Please sign in to comment.