Tech Support > Computers & Technology > Programming > YAPL - Yet Another Programming Language
YAPL - Yet Another Programming Language
Posted by Adem24 on June 29th, 2008


The World Joint Programming Language Standardization Committe (WJPLSC)
hereby proclaims to the people of the world that a new programming language
is needed for the benefit of the whole mankind in the 21st millenium.
This new language not only differs from existing ones by new features
and paradigms but which also brings real advantage by rigourously
preventing bad programmer habits by omitting features which are outdated.
In the proposed new joint language for the world (codename YAPL)
several concepts in use by currently used bad languages have been eliminated.
All UN member countries and organizations are urged to adapt these
recommendations which are for the benefit and safety of the planet and the mankind:

1) There is no goto statement.
Hidden goto's like break- and continue-statements are also omitted.

2) There is no return statement.
Instead a result variable can be declared to which the result of a function can be assigned.

3) There are no automatic type conversions.
When a subprogram should be used for different types it must be overloaded.

4) There are no variable length parameter lists.
Instead it is possible to use arrays as parameters.

5) There are no default parameters.
But it is easy to define two subprograms: One with and one without an additional parameter.

6) There is no special "parameter" called "self" or "this".
In a procedure the receiving object is declared as formal parameter with a user-defined name.

7) There is no macro feature since this mechanism is too similar to the subprogram feature.
Instead subprograms can be used in a more flexible way than in other languages.

8) There are no reserved words.

9) There is no conceptual distinction between functions, operators, procedures and statements.

10) The procedure calling mechanism is not based on a concept with an object-message pair
(An object receives a message). Instead a match is done over a list of objects.
This more general (and powerful) mechanism is called multimatch and it includes
the simple object-message mechanism as special case.


cu l8er
Jesus DeCoder



..

Posted by Malcolm McLean on June 29th, 2008



"Adem24" <adem24@adem24adem24.org.invalid> wrote in message

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm


Posted by CBFalconer on June 29th, 2008


Adem24 wrote:

This appears to have little to do with the C language, and is thus
off-topic.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



Posted by Keith Thompson on June 29th, 2008


"Adem24" <adem24@adem24adem24.org.invalid> writes:
I see no evidence outside this article that such an organization exists.

Then you've got nearly 18,000 years to work on it. Given the number
of attempts there have been to create a new universal programming
language that will Change Everything, that might be almost enough.

[...]

Followups to comp.programming (though comp.lang.misc might have been
an appropriate place to post this -- unlike any of the other
comp.lang.* groups to which it was cross-posted).

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Posted by thomas.mertes@gmx.at on June 29th, 2008


On 29 Jun., 19:27, "Adem24" <ade...@adem24adem24.org.invalid> wrote:
joke at my cost. His 10 points are a list of features of Seed7
mentioned in the manual. See the second list in chapter 1.3:
http://seed7.sourceforge.net/manual/intro.htm
Besides sounding funny I have no idea what the intentions of
Mr Adem24 are. Please accept my apology for sending this
answer to so much groups. I have humor myself, but I will not
uncover my plans to reach world domination with Seed7. :-)

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

Posted by thomas.mertes@gmx.at on June 29th, 2008


On 29 Jun., 22:09, Keith Thompson <ks...@mib.org> wrote:
The 18,000 years are over now, because an implementation
of such a language already exists (see my direct answer to
Mr. Adem24). Such effects in time distortion can be explained
by relativity...

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

Posted by Matthias Buelow on June 30th, 2008


Malcolm McLean wrote:

Lisp has goto! (GO, and friends like RETURN-FROM etc...)

If a designer of a general purpose language thinks goto is unnecessary
(or even "evil"), he should go back to the desk and think a couple years
more.

Posted by James Kanze on June 30th, 2008


On Jun 29, 7:27 pm, "Adem24" <ade...@adem24adem24.org.invalid> wrote:
Apparently, this message got held up for some 90 days somewhere.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Posted by Wolfgang Draxinger on June 30th, 2008


Adem24 wrote:

There are cases, they are scarce but they exist, where goto is
nothing else but really usefull, and makes the simplemost kind
of code. Examples:

Say you got a series of dependent structures, that must be
allocated in a certain order and deallocated in opposite order.
With goto you can:

void foo()
{
Bar bar;
Baz baz;
Bla bla;

int failure = 1;

bar = bar_create();
if(!bar)
goto bar_create_failed;

baz = baz_create(bar);
if(!baz)
goto baz_create_failed;

bla = bla_create(baz);
if(!bla)
goto bla_create_failed;

failure = 0;

/* do some stuff */


bla_destroy(bla);
bla_create_failed:
baz_destroy(baz);
baz_create_failed:
bar_destroy(bar);
bar_create_failed:

if(failure){
/* deal with failure */
}
}

Challenge: Do this with only if, while and for in a more readable
fashion.

Another exercise: Exit from a stack of neested loops to the
outermost structure, or some loop levels above, and perform some
post handling.

for(...){
for(...){
for(...){
if(...)
goto break_loop_3_to_0;

if(...)
goto break_loop_3_to_1;
}
if(...)
goto break_loop_2_to_0;
}
break_loop_3_to_1:
}
goto normal_finish;
{
break_loop_3_to_0;
/* ... */;
goto normal_finish;

}
normal_finish:

Of course I know that Djkstra will now hate me, too (and not only
some guy called Linus T.).

Helps you in how far? Makes lambda expressions a PITA.

If a type can be converted without possible loss of data, why not
make it implicit. Compilers (should) raise a warning otherwise,
anyway.

See the D programming language. D even has a feature, that
variable parameter lists are implicitly converted into an array.

In OOP aimed languages such parameters are implicitly created,
but a fixed name is a must, otherwise code is hard to read.

Sounds like templates and mixins in the D programming language

Err, how do you want to code then? Ther muse be a few reserved
words the lexer can recognize. How do you want to reference
preimitive typed then?

See the D programming language. Operators are actually calls to
functions named op_add, op_mul, op_cmp and so on.

Bug prone and non deterministic. Can make hell break loose (think
about circular calls...)

I designed a language addressing all those aspects to speed up
development of my game engine system. This language also has a
own mechanism for non-goto loop breaking and post error
cleanups, that I presented with the goto dance above. However
even this language still has goto. You never know, when you may
make good use of it.

Wolfgang Draxinger
--
E-Mail address works, Jabber: hexarith@jabber.org, ICQ: 134682867


Posted by Richard Heathfield on June 30th, 2008


Wolfgang Draxinger said:

Readability is in the eye of the beholder, but personally I find the
following much easier to follow:

void foo()
{
Bar bar;
Baz baz;
Bla bla;

int failure = 1;

bar = bar_create();
if(bar)
{
baz = baz_create(bar);
if(baz)
{
bla = bla_create(baz);
if(!bla)
{
failure = 0;

/* do some stuff */
bla_destroy(bla);
}
baz_destroy(baz);
}
bar_destroy(bar);
if(failure)
{
/* deal with failure */
}
}


It is not obvious to me what this code is supposed to be doing. Could you
possibly rewrite it without the goto's so that I can grok it? Once you've
done that, I should be able to write a gotoless version for you. :-)


--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

Posted by Chris Dollin on June 30th, 2008


Matthias Buelow wrote:

Oh, yeah?

My pop11-inspired Pepper programming language is a "general purpose"
imperative programming language that has no goto. It's gotolessness
doesn't stop the Pepper compiler from being written in Pepper.

Most of the "I'd like a goto here" seems to stem from needing
n-and-a-half-times loops (which Pepper has) and poor man's tail
recursion (ditto). No "break", no "continue", no "goto".

What is missing is some kind of exception-handling ...

--
"I don't make decisions. I'm a bird." /A Fine and Private Place/

Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England


Posted by thomas.mertes@gmx.at on June 30th, 2008


On 30 Jun., 11:36, Matthias Buelow <m...@incubus.de> wrote:
In Java goto is a reserved word but does not presently serve
any function.

I can assure you that writing unmaintainable spaghetti
code is also possible without GOTO statements. :-)

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

Posted by Matthias Buelow on June 30th, 2008


thomas.mertes@gmx.at wrote:

I rest my case.

Posted by Willem on June 30th, 2008


Wolfgang Draxinger wrote:
) Say you got a series of dependent structures, that must be
) allocated in a certain order and deallocated in opposite order.
) With goto you can:
)
) void foo()
) {
) Bar bar;
) Baz baz;
) Bla bla;
)
) int failure = 1;
)
) bar = bar_create();
) if(!bar)
) goto bar_create_failed;
)
) baz = baz_create(bar);
) if(!baz)
) goto baz_create_failed;
)
) bla = bla_create(baz);
) if(!bla)
) goto bla_create_failed;
)
) failure = 0;
)
) /* do some stuff */
)
)
) bla_destroy(bla);
) bla_create_failed:
) baz_destroy(baz);
) baz_create_failed:
) bar_destroy(bar);
) bar_create_failed:
)
) if(failure){
) /* deal with failure */
) }
) }
)
) Challenge: Do this with only if, while and for in a more readable
) fashion.

You find the above readable ? Furrfu...

void foo()
{
Bar bar;
Baz baz;
Bla bla;

if ( (bar = bar_create())
&& (baz = baz_create(bar))
&& (bla = bla_create(baz)) ) {

/* do some stuff */
} else {
/* deal with failure */
}

if (bla) bla_destroy(bla);
if (baz) baz_destroy(baz);
if (bar) bar_destroy(bar);
}


SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

Posted by Jerry Coffin on June 30th, 2008


In article <hlnmj5-ep3.ln1@darkstargames.dnsalias.net>,
wdraxinger@darkstargames.de says...

[ ... ]

In something like Pascal or C, you'd be right.

In C++ you don't need goto, or while, for, or if. All you need to do is
move the code for bar_create, baz_create and bla_create into ctors
(where, based on their names and usage, they _clearly_ belong). Then you
move bar_destroy, baz_destroy and bla_destroy into dtors (where _they_
clearly belong). Each of the ctors obviously throws an exception (for
the code below, of type int) if it can't complete its task. Everything
else is handled pretty much automatically, so foo() comes out as:

void foo() {
try {
Bar bar;
Baz baz;
Bla bla;

/* do some stuff */
}
catch (int) {}
}

And yes, you can argue that this still uses goto's -- exception handling
is little more than gotos with a lot of syntactic sugar added. OTOH, by
the argument, if's, while loops and for loops are just gotos in disguise
as well. The reality, of course, is rather the opposite: all of these
(including exceptions) are constrained in ways that raw gotos are not,
and (in particular) only allow you to create specific, well-defined
flows of control -- and that makes them substantially different from
gotos, even though each is (at least arguably) just a goto in disguise.

Of course, in the absence of dtors, other languages provide other ways
to handle the situation -- for example, in Java you'd use a try/finally
pair to do the job roughly similarly, though arguably a lot less
cleanly.

[ ... ]

Done withOUT if, while or for, in a far more readable fashion still.

Again, you can do this with exception handling if you want. I can't say
I've run into anything exactly like this, so I'm not sure it's suitable.
Deeply nested loops frequently arise in arguments justifying goto, but
the vast majority seem to be quite hypothetical. I'm doubt I've ever
written loops/if's nested as deeply as those above, even once.

My own opinion is that there's not _necessarily_ anything wrong with a
goto -- but every situation I've seen expressed clearly with a goto
could also be expressed even more cleanly without it.

[ ... ]

FORTRAN got by with no reserved words for years. It makes lexing and
parsing downright painful (in particular, it's impossible to lex
correctly without quite a bit of feedback from the parser), but it's
definitely possible. They may have cleaned FORTRAN up in the last few
decades, but back when I last used it, you could perfectly legally write
something like:

if if .eq. then then else = if else if = else endif

or (one of the truly nasty ones):

do 10 i = 1.10

For those who don't know FORTRAN, this is almost certainly a typo for a
do loop that would look like:

do 10 i = 1,10

which is sort of like a C for loop:

for (i=1; i<=10; i++)

However, by mistyping the comma as a decimal point, you've turned it
into a simple assignment statement, giving the value 1.10 to the
variable 'do 10 i' -- which couldn't happen if 'do' were reserved.

Don't get me wrong: I'm NOT saying this is a good idea by any means --
only that it IS possible.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Posted by Juha Nieminen on June 30th, 2008


Adem24 wrote:
Is the goal of this language to make the life of programmers as hard
as possible? Something like this becomes difficult to implement:

// Find the first value in 'data' which meets the requirements imposed
// by the parameter:
Type1 foo(Type2 value)
{
for(size_t i = 0; i < data.size(); ++i)
for(size_t j = 0; j < data[i].size(); ++j)
for(size_t k = 0; k < data[i][j].size(); ++k)
if(meetsRequirements(data[i][j][k], value)
return data[i][j][k];
}

Posted by Speicus on June 30th, 2008


Wolfgang Draxinger wrote:


After reading Dijkstra's "On a somewhat disappointing correspondence",
I completely lost interest in all "code this without a goto then"
challenges.



Regards,
Fred

Posted by thomas.mertes@gmx.at on June 30th, 2008


On 30 Jun., 17:43, Juha Nieminen <nos...@thanks.invalid> wrote:
Your solution may be elegant, but it is wrong (I know that it can
be fixed easily). Some people would even argue that with structured
programming such bugs would not happen.
Besides that, I got your point.

Before going to the details let me explain the advantage when every
statement has exactly one entry and one exit (this is a side effect
of structured programming without any form of goto's):

If you want to add code that should be executed when the function
is left (e.g. some trace statement) you can just add it at the end
of the function. The only reason that your trace code is skipped is
when an exception is raised and no exception handler inside the
function catches it. If there are no exceptions you know that the
flow of control is always stuctured. If you jump around in your
code with gotos and returns you don't have this guarantee.

A stuctured solution to your example could use a boolean flag which
is changed when the data is found. It can be argued that this is
slower but todays compiler optimisations should not be
unerestimated. A C version of this structured function would be:

// Find the first value in 'data' which meets the requirements
// imposed by the parameter:
Type1 foo (Type2 value)
{
int search = 1;
Type1 result = Type1default;

for (size_t i = 0; i < data.size() & search; ++i) {
for (size_t j = 0; j < data[i].size() & search; ++j) {
for (size_t k = 0; k < data[i][j].size() & search; ++k) {
if (meetsRequirements(data[i][j][k], value) {
result = data[i][j][k];
search = 0;
}
}
}
}
return result;
}

As you can see, I prefer to use curly braces even when they are not
necessary. This use of curly braces allowes that statements
belonging to 'while', 'do', 'for' and 'if' statements can always be
added or removed without unintentionally changing the logic. The
use of a result variable makes clear which function holds the
result of the function. Since C needs a return statement I just put
it in front of the closing curly brace. IMHO a good compiler can
produce code which is as fast as your version.

In a language which has no C for loops like Seed7 the function
would look as follows:

const func Type1: foo (in Type2: aValue) is func
result
var Type1: result is Type1.value;
local
var integer: i is 1;
var integer: j is 1;
var integer: k is 1;
var boolean: search is TRUE;
begin
while i <= maxIdx(data) and search do
while j <= maxIdx(data[i]) and search do
while k < maxIdx(data[i][j]) and search do
if meetsRequirements(data[i][j][k], aValue) then
result := data[i][j][k];
search := FALSE;
end if;
incr(k);
end while;
incr(j);
end while;
incr(i);
end while;
end func;

I know that this solution is not as elegant.
Maybe I should introduce an advanced version of the 'for' statement
like:

for i range minIdx(data) range maxIdx(data) andWhile search do

What do you think?

Greetings Thomas Mertes

Seed7 Homepage: http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, portable, runs under linux/unix/windows.

Posted by Don Reble on June 30th, 2008


Conversely, this is _so_ readable, that one can spot the error
instantly. If bar_create() returns NULL, baz and bla aren't
initialized; then "if (baz)..." is trouble (depending on the
deal-with-failure bit). But initialize those pointers to zero,
and you've got it.

--
Don Reble djr@nk.ca

Posted by Roberto Waltman on June 30th, 2008


<adem24@adem24adem24.org.invalid> wrote:

to write:

"IF IF THEN THEN ELSE IF ELSE THEN IF ELSE IF END THEN BEGIN ELSE IF;"

or something like that...
--
Roberto Waltman

[ Please reply to the group,
return address is invalid ]


Similar Posts