Subject: Re: Scripting with Visual Basic Clone
From: Tomasz Wegrzanowski (firstname.lastname@example.org)
Date: Thu Jun 29 2000 - 06:45:44 CDT
On Thu, Jun 29, 2000 at 12:04:46AM -0500, sam th wrote:
> On Thu, 29 Jun 2000, Tomasz Wegrzanowski wrote:
> > This isn't true Scheme is easy to learn.
> > For example, adding 2 + 2
> > People tend to think it is 2 + 2, not + 2 2 nor 2 2 +.
> > There are of course more such problems.
> OK, I've been challenged.
> Scheme Syntax in a few simple rules.
> - -----------------------------------
> 1) All expressions are surrounded by parenthesis.
> Example: (func arg1 arg2)
People are used to surround arguments by parenthesis.
(f x) looks strange comparing with f(x).
> 2) Everything is prefix.
> Example (+ 1 2) - this evaluates to 3
Math is most important kind of simple scripting.
It is important for script-math to look more or less like real math.
If one needs to count:
----------------- and ------------------
In most languages he only need to know how to change it to flat expresion.
`(sqrt(b*b-4*a*c)-b)/2', which is still mathematically-correct,
so he will probably do this without help, and know how to change
math sqrt symbol to sqrt().
In scheme :
(/ (- (sqrt (- (* b b) (* (* 4 a) c))) b) (* 2 a))
(/ (+ (sqrt (- (* b b) (* (* 4 a) c))) b) (* 2 a))
Is this any similar to real math ?
Is this correct ?
It's easier to make a uncorrectable (unfindable) typo in such expression
that to make a sigsegv in C.
People simply don't think prefix.
Sure, one can parse single-() in his head, but unless you have
different types of parens on display or many-months LISP experience,
you won't be even able to parse expressions above in reasonable time.
> 3) Bind some name to some value with define.
> Example: (define pi 3.14159)
> This works for functions too.
> 4) Return a function with lambda. Arguments come after the lambda.
> Example: This returns a function that squares its argument.
> (lambda (x)
> (* x x))
And lambda calculus is of course so widely known.
Functions aren't part of newbie's scripts anyway.
> 5) Conditionals with cond
> (test1) (exp1)
> (test2) (exp2))
Two tests in one conditional ?
Conditionals always takes one test.
> 6) Create a literal with '
> Example '(1 2 3) returns (1 2 3)
Unbalanced quotes. Y'know how people react for it.
> These are the basic rules of Scheme syntax. There are important, more
> complicated, and very useful additons, but lots can be done with these,
> and the following primitive (defined for you) functions.
> first - returns the first part of a list (first '(a b c)) -> a
> rest - returns the list without the first part (rest '(a b c)) -> (b c)
> and, or, equal? - self-explanatory
> +, -, / - integer ops
> display - outputs args to screen eg (display (first '(1 2 3)))
> I challenge anyone to reduce another language to as few rules. (other
> LISP derivatives excluded).
As few syntactic rules ?
I take a challenge.
Look at you-favourite-RISC-machine assembler.
EBNF for it looks like :
([label: ] operation [argument1 [argument2]] )*
Number of rules have more to do with complexity of parser
that with complexity of language.
C and bash have less tokens than Perl and Python.
Are they simpler because of this ?
Maximally simple real language is Smalltalk.
Its FULL syntax takes a few display pages,
but I don't have them here to show you.
It is probably more than SCHEME/*LISP, but these rules make
it much better looking and way easier to undestand :
5 "cats" * 2 "mice per cat" * 50 "gram of cheese per mice".
'2 + 2 * 2 = ' print.
"It is 8" 2 + 2 * 2.
'2 + 2 squared = ' print.
"It is 6" 2 + 2 squared.
This archive was generated by hypermail 2b25 : Thu Jun 29 2000 - 07:06:15 CDT