Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: Declaration...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 41 of 50 Topic 1065 of 1217
Post > Topic >>

Re: Declaration design preference: type or name first

by James Harris <james.harris.1@[EMAIL PROTECTED] > Nov 11, 2007 at 10:10 AM

On 6 Nov, 08:39, torb...@[EMAIL PROTECTED]
 (Torben =C6gidius Mogensen)
wrote:

..=2E.

> > var <array (0 ... 255) of <char>> translate_table  #Compound type
>
> Why the brackets around char in the last example?  The outer brackets
> should be enough to establish that we are talking about types.

Perhaps. My declaration system is far from complete yet.

..=2E.

> Yes, but here we are talking about a function g, which returns an int
> and takes as its parameter a function f which takes as its parameter
> an array of ten integers and returns an int.

OK. I see your point about the invented name in the original C.

..=2E.

> > Sorry, can't bring myself to go with inferred types. (Why do you like
> > them?)
>
> For several reasons:
>
>  1. It makes the programs shorter.

But it also makes them ambiguous.

>  2. You don't have to decide in advance how polymorphic/generic your
>     functions are -- the type inference makes them maximally
>     polymorphic.

I want control over how polymorphic functions are. Maximally
polymorphic doesn't sound good to me. On the other hand I intend
arbitrarily-parameterised types which would allow the necessary
polymorphism but retain control.

>  3. It makes it easier to refactor your programs, as you don't have to
>     change a zillion declarations when you, say, change something from
>     a list to an array.  Of course, if you use typedefs all over the
>     place, you can change a single typedef instead of a zillion types,
>     but that requires discipline.

For this I intend a type system that allows incoming parameters to be
behaviourally specified - e.g. "sequence of" - whereas the actual
parameter supplied can be concrete such as "array of" or "file of"
etc. I take your point about typedefs. Not sure how best to encourage
the use of type names.

> > I want the user to explicitly specify all types. Inferred types
> > seems to me too likely a cause of unexpected errors. That's maybe
> > because I have never used them but I'm thinking of this as an
> > engineering tool and expect all types to be stated.
>
> I have used languages with type inference for two decade, and in my
> experience, the compiler spots type errors about as well as if you
> stated them explicitly.  Type errors are usually of the form "These
> two uses of a variable/function do not agree, because one use implied
> a type of form A and the other a type of form B, which are not
> compatible", so you have to figure out which of the two uses are
> wrong, which is a bit harder than if you just get a single use that
> doesn't fit a declaration.  But it is not really a problem in my
> experience.
>
> I would still make type declarations optional, so you can specify your
> intent to the compiler and to readers of your code.

Perhaps the type parameterisation and partial typing would address
your preferences. In truth, adding type inference to a compiler adds
greatly to its complexity. I'm finding that writing the compiler
without type inference is more than enough of a challenge!

> I prefer a combination of type inference with optional declarations
> over both dynamic types and explicit static type declarations, both of
> which I have also used extensively.
>
> So, before you finalize your design, you should read up on type
> inference.  Even if you end up not using it, you at least have the
> satisfaction of making that decision on an informed basis.

I've read some about it. I do have what you may call optional
declarations, or rather optional parts of declarations. Part of the
ethos of my language is toward more explicit specification rather than
less. General type inference would not fit well with that and would be
an anomalous addition. I will, however, bear your comments in mind.
There may be ways to satisfy the requirements while maintaining the
engineering discipline. As I say, this is work in progress.....

--
James
 




 50 Posts in Topic:
Declaration design preference: type or name first
James Harris <james.ha  2007-10-30 06:25:49 
Re: Declaration design preference: type or name first
Christopher Barber <cb  2007-10-30 12:04:41 
Re: Declaration design preference: type or name first
Robbert Haarman <comp.  2007-10-31 11:18:39 
Re: Declaration design preference: type or name first
Marco van de Voort <ma  2007-10-31 14:53:22 
Re: Declaration design preference: type or name first
"cr88192" <c  2007-10-31 08:29:19 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-10-30 16:01:31 
Re: Declaration design preference: type or name first
"cr88192" <c  2007-10-31 11:22:00 
Re: Declaration design preference: type or name first
Logan Shaw <lshaw-usen  2007-10-30 21:54:26 
Re: Declaration design preference: type or name first
Mike Sieweke <msieweke  2007-10-31 22:47:45 
Re: Declaration design preference: type or name first
CBFalconer <cbfalconer  2007-10-31 22:38:47 
Re: Declaration design preference: type or name first
Marco van de Voort <ma  2007-11-01 08:38:05 
Re: Declaration design preference: type or name first
Logan Shaw <lshaw-usen  2007-10-31 23:45:26 
Re: Declaration design preference: type or name first
Mike Sieweke <msieweke  2007-11-01 21:26:24 
Re: Declaration design preference: type or name first
Richard Heathfield <rj  2007-11-01 05:31:44 
Re: Declaration design preference: type or name first
Marco van de Voort <ma  2007-11-01 08:39:55 
Re: Declaration design preference: type or name first
Richard Heathfield <rj  2007-11-01 08:59:25 
Re: Declaration design preference: type or name first
Marco van de Voort <ma  2007-11-01 08:38:56 
Re: Declaration design preference: type or name first
cri@[EMAIL PROTECTED] (R  2007-11-01 14:40:44 
Re: Declaration design preference: type or name first
ram@[EMAIL PROTECTED] (S  2007-11-01 14:50:16 
Re: Declaration design preference: type or name first
cri@[EMAIL PROTECTED] (R  2007-11-01 15:52:23 
Re: Declaration design preference: type or name first
Logan Shaw <lshaw-usen  2007-11-01 20:09:07 
Re: Declaration design preference: type or name first
cri@[EMAIL PROTECTED] (R  2007-11-02 03:52:34 
Re: Declaration design preference: type or name first
Logan Shaw <lshaw-usen  2007-11-02 00:57:24 
Re: Declaration design preference: type or name first
cri@[EMAIL PROTECTED] (R  2007-11-03 15:53:21 
Re: Declaration design preference: type or name first
"cr88192" <c  2007-11-03 22:27:59 
Re: Declaration design preference: type or name first
thomas.mertes@[EMAIL PROT  2007-10-30 23:48:38 
Re: Declaration design preference: type or name first
thomas.mertes@[EMAIL PROT  2007-10-31 00:12:07 
Re: Declaration design preference: type or name first
torbenm@[EMAIL PROTECTED]  2007-10-31 09:27:23 
Re: Declaration design preference: type or name first
thomas.mertes@[EMAIL PROT  2007-10-31 01:38:54 
Re: Declaration design preference: type or name first
Marco van de Voort <ma  2007-10-31 14:45:15 
Re: Declaration design preference: type or name first
Ed Prochak <edprochak@  2007-10-31 17:28:45 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-01 13:56:47 
Re: Declaration design preference: type or name first
"cr88192" <c  2007-11-02 16:01:12 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-02 01:08:01 
Re: Declaration design preference: type or name first
CBFalconer <cbfalconer  2007-11-02 07:51:18 
Re: Declaration design preference: type or name first
Tzy-Jye Daniel Lin <dt  2007-11-03 03:28:22 
Re: Declaration design preference: type or name first
"cr88192" <c  2007-11-03 21:54:27 
Re: Declaration design preference: type or name first
torbenm@[EMAIL PROTECTED]  2007-11-05 09:56:58 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-05 10:33:42 
Re: Declaration design preference: type or name first
torbenm@[EMAIL PROTECTED]  2007-11-06 09:39:46 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-11 10:10:54 
Re: Declaration design preference: type or name first
Robbert Haarman <comp.  2007-11-12 12:17:10 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-12 15:18:18 
Re: Declaration design preference: type or name first
Robbert Haarman <comp.  2007-11-13 09:43:11 
Re: Declaration design preference: type or name first
torbenm@[EMAIL PROTECTED]  2007-11-13 10:14:08 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-13 15:47:48 
Re: Declaration design preference: type or name first
Robbert Haarman <comp.  2007-11-14 03:36:24 
Re: Declaration design preference: type or name first
anw@[EMAIL PROTECTED] (D  2007-11-14 13:11:46 
Re: Declaration design preference: type or name first
torbenm@[EMAIL PROTECTED]  2007-11-14 11:36:07 
Re: Declaration design preference: type or name first
James Harris <james.ha  2007-11-13 16:04:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 18:14:10 CDT 2008.