www.digitalmars.com         C & C++   DMDScript  

D - Syntactical ideas.

reply Ilya Minkov <midiclub 8ung.at> writes:
I've been collecting ideas for D and have a couple.


  - Shortcut object access.

If you have asome long path to the object currently processing you could 
write:

with MainForm.BigPanel.ThisButton do {
	Text = "Blah";
	Width = 40;
	some_external_variable = 1;
}

Please note that external object access should be no problem, and name 
conflicts are resolved with higher priority to the with statement.

This idea has been taken from Delphi.


  - Optional separators in numbers would increase readability, for example:

int Million = 1_000_000;
float Pi = 3.14159_26535_89793;

This idea has been taken from ADA-95.


  - Non-decimal numbers in every possible base: 'base#number', where 
base need not be bound to usual 2,8 and so on. However, more than 36 
doesn't appear possible or make sense: 10 decimals and 26 letters of 
alpabet.

This idea has been taken from GPC, the GNU Pascal Compiler.


Please also read about the ocaml-like patternmatcher.


-i.
Dec 29 2002
next sibling parent reply Patrick Down <pat codemoon.com> writes:
Ilya Minkov <midiclub 8ung.at> wrote in
news:aunba2$5ct$1 digitaldaemon.com: 

 I've been collecting ideas for D and have a couple.
 
 
   - Shortcut object access.
 
http://www.digitalmars.com/d/statement.html#with
Dec 29 2002
parent Ilya Minkov <midiclub 8ung.at> writes:
Sorry, overlooked. I'm new to D.

Patrick Down wrote:
 Ilya Minkov <midiclub 8ung.at> wrote in
 news:aunba2$5ct$1 digitaldaemon.com: 
 
 
I've been collecting ideas for D and have a couple.


  - Shortcut object access.
http://www.digitalmars.com/d/statement.html#with
Dec 30 2002
prev sibling next sibling parent reply "Walter" <walter digitalmars.com> writes:
"Ilya Minkov" <midiclub 8ung.at> wrote in message
news:aunba2$5ct$1 digitaldaemon.com...
   - Optional separators in numbers would increase readability, for
example:
 int Million = 1_000_000;
 float Pi = 3.14159_26535_89793;

 This idea has been taken from ADA-95.
Does any language but ADA do this? If not, I'm not sure how useful in practice it is. It has the advantage of being simple to implement.
   - Non-decimal numbers in every possible base: 'base#number', where
 base need not be bound to usual 2,8 and so on. However, more than 36
 doesn't appear possible or make sense: 10 decimals and 26 letters of
 alpabet.

 This idea has been taken from GPC, the GNU Pascal Compiler.
I'm sorry, but I haven't in 25 years of programming ever seen any use for bases other than binary, octal, decimal, and hex, and octal appears to now be obsolete. There was a thread here a while back about dumping support for octal.
Jan 21 2003
next sibling parent reply Norbert Nemec <nobbi_at_theorie3.physik.uni-erlangen.de NOSPAM.COM> writes:
Walter wrote:

 
 "Ilya Minkov" <midiclub 8ung.at> wrote in message
 news:aunba2$5ct$1 digitaldaemon.com...
   - Optional separators in numbers would increase readability, for
example:
 int Million = 1_000_000;
 float Pi = 3.14159_26535_89793;

 This idea has been taken from ADA-95.
Does any language but ADA do this? If not, I'm not sure how useful in practice it is. It has the advantage of being simple to implement.
Sather does - the idea having been taken from Ada95, I suppose. :-) I'd say, just include it. Doesn't hurt anybody, and obviously at least a few people like it.
Jan 22 2003
parent "Walter" <walter digitalmars.com> writes:
"Norbert Nemec" <nobbi_at_theorie3.physik.uni-erlangen.de NOSPAM.COM> wrote
in message news:b0logj$rim$2 digitaldaemon.com...
 I'd say, just include it. Doesn't hurt anybody, and obviously at least a
few
 people like it.
Every added feature makes the language larger and buggier. I need a compelling case for a new feature.
Jan 26 2003
prev sibling parent reply Ilya Minkov <midiclub tiscali.de> writes:
LX appears to implement both of these ideas.

As to the use of base#num, you could eliminate the octal "0123" numbers 
which is more often a bug than not. If someone needs octal, he would write:


Hm. Can't think of any real use. Maybe some scientists among here show 
up and give an idea?


Walter wrote:
 "Ilya Minkov" <midiclub 8ung.at> wrote in message
 news:aunba2$5ct$1 digitaldaemon.com...
 
  - Optional separators in numbers would increase readability, for
example:
int Million = 1_000_000;
float Pi = 3.14159_26535_89793;

This idea has been taken from ADA-95.
Does any language but ADA do this? If not, I'm not sure how useful in practice it is. It has the advantage of being simple to implement.
  - Non-decimal numbers in every possible base: 'base#number', where
base need not be bound to usual 2,8 and so on. However, more than 36
doesn't appear possible or make sense: 10 decimals and 26 letters of
alpabet.

This idea has been taken from GPC, the GNU Pascal Compiler.
I'm sorry, but I haven't in 25 years of programming ever seen any use for bases other than binary, octal, decimal, and hex, and octal appears to now be obsolete. There was a thread here a while back about dumping support for octal.
Jan 22 2003
next sibling parent Russell Lewis <spamhole-2001-07-16 deming-os.org> writes:
Ilya Minkov wrote:
 LX appears to implement both of these ideas.
 
 As to the use of base#num, you could eliminate the octal "0123" numbers 
 which is more often a bug than not. If someone needs octal, he would write:

 
 Hm. Can't think of any real use. Maybe some scientists among here show 
 up and give an idea?
Seems like varied-base numbers are far more important for user I/O than for programming constants. After all, you can always code it manually, and comment your code: int foo = 83; // 83 decimal is 123 octal
Jan 22 2003
prev sibling parent reply "Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> writes:
"Ilya Minkov" <midiclub tiscali.de> escreveu na mensagem
news:b0m1s6$119k$1 digitaldaemon.com...
 LX appears to implement both of these ideas.

 As to the use of base#num, you could eliminate the octal "0123" numbers
 which is more often a bug than not. If someone needs octal, he would
write:


 Hm. Can't think of any real use. Maybe some scientists among here show
 up and give an idea?
During my physics grad course I'd never used anything except base 10. Sometimes I toy around with hex or binary, but I can convert between them easily, so no problem here. If D had any syntax for arbitrary bases, each line of code using them for anything else octal, binary or hexadecimal would raise my bug alarm. But it would be great for obfuscation ;-) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.443 / Virus Database: 248 - Release Date: 10/1/2003
Jan 22 2003
parent Ilya Minkov <midiclub 8ung.at> writes:
Daniel Yokomiso wrote:

During my physics grad course I'd never used anything except base 10. Sometimes I toy around with hex or binary, but I can convert between them easily, so no problem here. If D had any syntax for arbitrary bases, each line of code using them for anything else octal, binary or hexadecimal would raise my bug alarm. But it would be great for obfuscation ;-)
Right. Storing lowercase text in a compressed form :> -i.
Jan 22 2003
prev sibling parent Ilya Minkov <midiclub tiscali.de> writes:
I'm currently reading Extended Pascal manual.

---8<---

12. Set extensions

A new operator >< is defined, which takes the symmetric difference of 
two set values; there is a new predefined function card which returns 
the cardinality of a set (the number of members present); and the FOR 
statement allows a new form in which the control variable is given in 
turn the values defined by a set.

     FOR n IN setvalue DO ...

--->8---

I've already heard something similar was intended. Just that it's not 
very practical without a "set" definition :) There it comes back - i 
remember to have seen some advocates of pascal "set" a long time ago.

If set is not introduced as a separate type, it should be possible to 
handle almost anything as a set. This might be good, since bitarrays and 
associative arrays have a kind of similar behaviour.

BTW, that leads me to an idea that a separate implementation of 
associative arrays can be made for small-ranged types. This would be 
better than a Pascal's set, since it was limited to no more than 
byte-indexed, and a associative array of bit has a similar semantics but 
is more flexible. Just the performance may be tuned? Is there a 
reasnoable way for 2 implementations to interact? I'll think about it.

-i.
Mar 17 2003