Moto 0.19.0 beta 2

David Hakim <dhakim-Gkm/TONP9n1Wk0Htik3J/[email protected]> Mon, 10 Mar 2003 21:34:16 -0500
Newsgroups gmane.comp.lang.moto.devel,gmane.comp.lang.moto.user
Message-ID <[email protected]>
	The second beta of Moto 0.19.0 is ready. You can download it from  
http://www.projectmoto.org/moto_0_19_0_eng_b.tar.gz .

	What this release adds over and above the ability to declare and use 
Higher Order Functions is the ability to create new functions 
dynamically by 'partially applying' existing functions. Say for example 
you want to create a function to square two numbers. In cstdlib there 
is a function pow() which takes two doubles and returns the first to 
the power of the second. We can create a 'square' function by partially 
applying the pow() function:

	double(double) square = pow(?,2);

	We can then call the square function like any other function.

	print "square(3) = "+ square(3) + "\n";

	We could also apply the other argument of the pow function to create 
the function twoToThePow():

	double(double) twoToThePow = pow(2,?);
	print "twoToThePow(4) = "+ twoToThePow(4) + "\n";

	The real reason partial application is cool however is because it lets 
you create callback functions.  For instance we can define the function 
add() which calls the add() method on a particular Vector.

	Vector v1 = new Vector();
	void(Object) add = v1.add;
		
	Now every time we call add() the added value gets added to v1.

	add("hello");
	add("goodbye");
	add("hello");
	add("goodbye");
	add("so");
	add("long");
				
	A more powerful use of callback is passing the add() method on a 
container like a Vector or Set to the each() method of an enumeration.  
:

	Vector v2 = new Vector();	
	v1.elements().each(v2.add);
	print "Cloned: "+ join(<String[]><Object>v2.toArray(),",") + "\n";
		
	v2.sort(<int(Object,Object)>strcmp);
	print "Sorted: "+ join(<String[]><Object>v2.toArray(),",") + "\n";
	
	v2.clear();
	Stringset s1 = new Stringset();
	v1.elements().each(<void(Object)>s1.add);
	s1.elements().each(v2.add);
	print "Unique: "+ join(<String[]><Object>v2.toArray(),",") + "\n";	
	This beta is now basically functionally complete so please let me know 
what bugs you guys find. I'm hoping to release by the end of the week.

-Dave

BTW: Here are the release notes for everything that's been added to 
Moto 0.19.0

New Features
- Added First-class type support for functions
- Added support for defining higher order functions
- Added support for dynamically generating new functions through the 
partial application of functions and methods
- Added Vector::sort(int(Object)) which takes a function to compare 
objects
- Added Enumeration::each(void(Object)) which takes a function to 
perform on each element in the enumeration
- Added sub(Regex,String(Match)) which takes a function for the 
substitution
- Added split() and join() functions
- Better errors are reported for bad casts of arrays
- Provided for https redirects (Shay)
- Added destdir support to the main makefile facilitating the creation 
of RPMs (Stefano)

Bugs Fixed
- Fixed a bug in PosixFileIO that caused a segfault in the 
MidafternoonCommander example
- Fixed a bug that would cause name collision in compiled code when a 
class had a no-arg constructor
- Fixed a bug that let all reference types be explicitly castable to 
all other reference types without first being cast to Objects
- Fixed a bug in the memory manager that would sometimes let collisions 
between the free list and the shared segment get by unnoticed
- Fixed --with-mysql and --with-pgsql configuration on a number of 
different platforms (Shay)
- Patched "mx/codex/db/pgsql/configure.in" file so that it figures out 
if OpenSSL
support is needed or not and acts accordingly (Shay)
- Fixed compilation problems related to moto.y syntax errors on certain 
FreeBSD installations (thanks Jack!)
- Fixed a rare exception in the compiler that would in very strange 
cases be generated when freeing motovals

Code Cleanup
-Refactored the moto type system
-Refactored motoi_fn
-Refactored motofunction related functions out of dl.c and env.c and 
into motofunction.c
-Removed switches on the opcount from motoX_fn and motoX_new
-Cleaned up a bunch of unnecessary checks in moto.y prior to list 
addition
-Made sure all non-terminals that return lists return ONLY lists
- Started factoring common code out of motoc motoi and motov into motox