Sunday, December 7, 2008

philosophy of duality of syntax

Now for a more text-ful approach to describing the problem and my approach towards a solution. It's interesting that as I have been slowly changing php to suit my needs I have been grappling with the issue of consistency much like the developers of py3k have. It seems that in an attempt to "make things consistent" they have tried to make everything work like a function i.e. no more print 'string', now it is print('string') - this feels, to me, like they took the wrong fork in the road. Instead of making print work like a function why not make all functions work like keywords/in built functions?

I guess I am in my ivory tower but really if I am going to create a language/dialect which I ENJOY coding in day in/day out I am not worried about backward compatibility and or what people are used to - I am worried about what makes things consistent and beautiful. The obvious choice for the most consistent approach would be straight s-expressions but there is something to be said for the readability of declaration and assignment. My approach is basically s expressions with out the initial brackets i.e.

$x = func arg:val arg1:val2 arg2:(func1 arga:vara);

(setf x (func arg:val arg1:var arg2:(func1 arga:vara)));

Now I can fully see how the s-expression is more perfectly recursively consistent but I personally find the prior approach more readable and for "in the main" programming it would be the most maintainable.

Something I have been toying with is the idea of how to transmogrify dynamic function calls in s-expressions:

$decide = [$char | $char == a ? sum : mul];

$num = 10;
$letter = a;
$result = ($decide char:$letter) 6 6 ($num + 50);

#should become
$result = sum 6 6 ($num + 50);

#which becomes
$result = sum(6,6,($num + 50));

No comments: