The Artima Developer Community
Sponsored Link

Weblogs Forum
if u cn rd ths ...

12 replies on 1 page. Most recent reply: Sep 11, 2005 7:50 AM by Christopher Diggins

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 12 replies on 1 page
Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

if u cn rd ths ... (View in Weblogs)
Posted: Aug 31, 2005 10:41 PM
Reply to this message Reply
Summary
Since Heron syntax is C++ based, I am experimenting to see what happens when you drop the requirement for the this keyword.
Advertisement
In my attempt to mimic C++ syntax, but increase flexibility I have ended up with a legal statement which may raise eyebrows:
  * * *;
The * as a unary operator by default means *this. The * as a binary operator commonly means multiply (it maps to a function _star). So * * * will in some cases result in a square operation. This should not be confused with *** which maps to the function: _star_star_star when used as a binary operator, or to _pre_star_star_star() when used as a unary operator.

I can write the BNF rules unambiguously, but the question is, is this a very bad idea?


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: if u cn rd ths ... Posted: Aug 31, 2005 11:45 PM
Reply to this message Reply
I thought the whole idea behind Heron is simplicity?
With your suggestion - or intended introduction of
sticking in * in that manner could become extremely
cryptic on Large Scale Systems. Unless you intend
Heron to be a language for very basic Mathematical
operations.

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: if u cn rd ths ... Posted: Sep 1, 2005 4:58 AM
Reply to this message Reply
It looks perfectly reasonable compared to Befunge, Malborge, Unlambda and a few other languages I know of.

But seriously, there is only so much you can do to protect people from themselves. In many languages you can make all your identifiers runs of underscores: _ + __ == ___.

John D. Mitchell

Posts: 244
Nickname: johnm
Registered: Apr, 2003

Re: if u cn rd ths ... Posted: Sep 1, 2005 8:55 AM
Reply to this message Reply
> I can write the BNF rules unambiguously, but the question
> is, is this a <b>very bad</b> idea?

A Very Bad Idea(tm). :-)

That "compression" leads to a horrible violation, IMHO, of things like distinctiveness and the Principle of Least Astonishment.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: if u cn rd ths ... Posted: Sep 1, 2005 9:06 AM
Reply to this message Reply
In the context of things like:

  _plus(self x) : self {
    result = *; // * instead of *this
    result += x;
  }
  _pre_inc_inc() : self* {
    ++data;
    result = @; // @ instead of this
  }


Is it still so bad? It just seems that this is unneccessary and that we keep it around out of habit.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: if u cn rd ths ... Posted: Sep 1, 2005 9:12 AM
Reply to this message Reply
> I thought the whole idea behind Heron is simplicity?

That is an important goal. I could make the case that * means *this is simpler, partly because it removes a keyword.

> With your suggestion - or intended introduction of
> sticking in * in that manner could become extremely
> cryptic on Large Scale Systems.

I am not sure I see that. If * by itself means *this, then it seems pretty uncryptic.

> Unless you intend
> Heron to be a language for very basic Mathematical
> operations.

Definitely in Heron mathematical operations are overloadable. The primitives are all library defined. In important goal for me is to eventually have a standard library mathematics package which rivals specialized languages Mathematica and Maple.

Max Lybbert

Posts: 314
Nickname: mlybbert
Registered: Apr, 2005

Re: if u cn rd ths ... Posted: Sep 1, 2005 12:27 PM
Reply to this message Reply
Take a look at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1509.pdf page 12 ("Consider: vector<int> v(istream_iterator<int>(cin), istream_iterator<int>()); Contrary to the expectation of many (us included) who innocently tried, this does not declare a variable v of type vector<int> initialized with a sequence of ints read from the standard input. Rather, it declares a function named v, taking two istream_iterator<int>s and returning a vector<int>." that "us" includes Stroustrup).

It's not a shock that the complexities of a language lead to constructs like * * *, and I don't think it's realistically possible to avoid.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: if u cn rd ths ... Posted: Sep 1, 2005 10:42 PM
Reply to this message Reply
> I could make the case that * means *this is simpler,

I guess it all depends on your idea of simplicity to
me simplicity would involve a language being intuitive.
Now I haven't done too much C++, but if it mean anything
close to what it means in Java, the "this" keyword
clarifies the concept of OO programming much more than
leaving it out. We all know that "this" refers to
"this object". On the other hand if you take simplicity
to mean less characters in a line of code then leaving
out this would make sense from that angle.

> I am not sure I see that. If * by itself means *this, then
> it seems pretty uncryptic.

Personally I think the fact that Java bring to some
extent C++ (at least from the little I've done), brings
across a sense of simplicity and ease of learning from
the fact that it is mapped out in Objects that one
can visualize conceptualize from a real world point of
view (which is why a language like Java is great for
a Newbie - it enables one to visualize large scale systems
in a very modular format - at which point one only concerns
himself with the glue logic and can concentrate on design.
With a whole bunch of *s, that will take away from
creating a language that is closer to human form.
I thought that was the whole idea of Highlevel languages
- to bring it closer to human-like statements.

does having "*this" not make things much more clear
than eliminating four extra characters? Anyways, I
guess its a matter of opinion.

Anyways, I must say man - its great to see you tackle
such a task. I wish you success. I don't want to be
like all these haters simply knocking on your achievements
and endeavours coz they don't seem to have the "sack of
rocks" to go at such an ardous task themselves.

Hope it (Heron) hits the mainstream at some point.

Spike

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: if u cn rd ths ... Posted: Sep 4, 2005 9:57 AM
Reply to this message Reply
> I guess it all depends on your idea of simplicity to
> me simplicity would involve a language being intuitive.
> Now I haven't done too much C++, but if it mean anything
> close to what it means in Java, the "this" keyword
> clarifies the concept of OO programming much more than
> leaving it out. We all know that "this" refers to
> "this object". On the other hand if you take simplicity
> to mean less characters in a line of code then leaving
> out this would make sense from that angle.

I have thought about it for the last several days, and I am now convinced that you are right and I should not allow unary operators without the this keyword. Those four letters will go along way to keep the language from looking like BrainF**k ( http://www.muppetlabs.com/~breadbox/bf/ )

> Anyways, I must say man - its great to see you tackle
> such a task. I wish you success. I don't want to be
> like all these haters simply knocking on your
> achievements
> and endeavours coz they don't seem to have the "sack of
> rocks" to go at such an ardous task themselves.
>
> Hope it (Heron) hits the mainstream at some point.

Very kinds words Spike, thank you.

Tim LS

Posts: 37
Nickname: parchandri
Registered: Jul, 2005

Re: if u cn rd ths ... Posted: Sep 9, 2005 10:03 PM
Reply to this message Reply
Terrible idea. I think having both unary and binary versions of any operator is a terrible idea.

C set a bad precedent for this with pointers (*).
C also has binary unary + and -, but there is no need for the unary versions, strictly.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: if u cn rd ths ... Posted: Sep 10, 2005 5:00 AM
Reply to this message Reply
> Terrible idea. I think having both unary and binary
> versions of any operator is a terrible idea.

I'll bite, why?

> C set a bad precedent for this with pointers (*).
> C also has binary unary + and -, but there is no need for
> the unary versions, strictly

What would you do instead of:

x = -y;
a = !b;
i = ++j;

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: if u cn rd ths ... Posted: Sep 10, 2005 5:37 PM
Reply to this message Reply
Isn't only one of your examples using an operator that's both unary and binary?

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: if u cn rd ths ... Posted: Sep 11, 2005 7:50 AM
Reply to this message Reply
> Isn't only one of your examples using an operator that's
> both unary and binary?

You are right, I made a mistake, because I was thinking of Heron. Nonetheless, I don't see the problem.

Flat View: This topic has 12 replies on 1 page
Topic: QA and TDD Previous Topic   Next Topic Topic: Heron 0.5.9.9

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use