caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Future of labels, and ideas for library labelling
@ 2001-04-03  7:27 Arturo Borquez
  0 siblings, 0 replies; 53+ messages in thread
From: Arturo Borquez @ 2001-04-03  7:27 UTC (permalink / raw)
  To: garrigue; +Cc: caml-list

Hi Jacques:
Some personal history with labels. At 70's I was involved in software development in CICS/VS (IBM/370) The IBM Macro-Assembler supported the use of labels and they were (are) very handly. That labels have the following properties (if my mind don't betray me)

1) In absolute abcence of labels the macros accepted parameters by position (as normal without labels).

2) Labeled parameters could be passed 'out of position' doing things very happy. (as in commuted mode)

3) Macros could be partial labeled, and all of those unlabeled parameters where (are) passed in order (after labeled parameters are assigned) in the 'empty holes' as in 1) by order.

4) the use of labels at the caller were (are) optative for labeled parameters (free or idiosincratic choice of the programmer).

ie:
(not OCaml code)

function1(text:t,pos:(x,y),mode:m,highlight:h)
body .......... etc

So we could write some variations:

1) function1("A Text",10,14,normal,on) completly by position with any label.

2) function1 (pos=(10,14),
              normal,on <-- mode & highligth
              text="A Text")
 Using labeling partially, so in this case unlabeled params at the caller are resolved after 'pos' and 'text' are filled taking the 'empty holes', first 'normal' is placed in 'mode' and second 'on' is places in 'highlight'.

By those years I coded a 8080 uCPU prepocessor copying this idea and worked fine.

Some experiments with OCaml showed me (if I am right) in the 'classic/normal' mode we can use labels always in order (position) and optional to use it or not.
ie;

# let f ~a b = a + b;;
val f : a:int -> int -> int = <fun>
# f 1 2;;
- : int 3

same result with f ~a:1 2, but drops error if we write f 1 ~a:2, so obviously classic mode not commute!. Also specifying defaults and partial application works! 

Now see labels in commuting mode (#labels true;;)

# f 2 ~a:1;;
- : int = 3;; commuting works! but
# f 1 2;; fails! (this arg. cannot be applied with...)

So in commuting mode labels must be always specified! you gain 'position freedom' and lose optional label use of 'classic mode'.

In my example of IBM Macro-Assembler you have both, optative labeling (of labeled functions) and arbitrary position for labeled arguments. 

For my 'personal taste' it would be very cool that the commuting mode preserve all properties of 'classic-mode'. Sorry but I don't know if there is a mathematical impediment (currying type inference or other) or only is an implementation issue. If this option 'is possible' it seems me that there is no need to change any 'labeled or unlabeled' library, and the goal to fit all in a single mode is achieved.

if I am wrong, please be indulgent with a beginner.

Best Regards.
Arturo Borquez


Find the best deals on the web at AltaVista Shopping!
http://www.shopping.altavista.com
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 53+ messages in thread
* Re: [Caml-list] Future of labels, and ideas for library labelling
@ 2001-04-17 11:53 Poigné
  0 siblings, 0 replies; 53+ messages in thread
From: Poigné @ 2001-04-17 11:53 UTC (permalink / raw)
  To: caml-list

Hello

being out of office I have started to read all the contributions about
labelling and gave up halfway through. I noticed the mail by Filliatre
to which I subscribe without reservation. 

I AM A HAPPY USER OF THE CLASSIC MODE

and so far did not find it necessary to use labels. I should say that I
have written with collegues quite a lot of code as a part of the
compiler and programming system of sE (that is a language that extends
Java by synchronous programming - combining the Esterel, Lustre, and
Statecharts dialects, generating C for instance. By the way, interest
welcome). I extensively use partial evaluation for a rigorous
denotational style semantics for the synchronous sublanguage. In fact I
suspect that I could not have suceeded without partial evaluation (to
comment on another thread). In order not to loose track, a good naming
discipline is necessary (which is probably equivalent to use labels in
this context without, personal view, cluttering the code: how awful to
write ~f: if I know the argument is a function - by position and since I
tend to use names that mean something).

On the other hand, I have programmed quite a substantial gui using the
most elementary Tk-binding. What I did is to built my own little set of
Ocaml functions for hiding Tk. I admit that labels might have helped for
dealing with optional arguments, though I probably would have done the
same. 

Hence a my vote: 

- If you feel you have to add labelling keep it optional.

Axel

PS. This will be my only contribution to the subject

-- 

Dr.rer.nat. Dipl.Ing. Axel Poigne            http://ais.gmd.de/~ap 
                                             mailto:poigne@gmd.de
GMD - AiS                                    Tel: (+) 2241 142440
Schloss Birlinghoven                         Fax: (+) 2241 142324
D-53754 Sankt Augustin
Germany 

------------------------------------------------------------------
See what happened at the workshop on
"Formal Design of Safety Critical Embedded Systems" (FEmSys'01) 
   http://ais.gmd.de/~ap/femsys
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 53+ messages in thread
* Re: [Caml-list] Future of labels, and ideas for library labelling
@ 2001-04-11 10:48 Francois-Rene Rideau
  0 siblings, 0 replies; 53+ messages in thread
From: Francois-Rene Rideau @ 2001-04-11 10:48 UTC (permalink / raw)
  To: caml-list

[Sorry about late mail and missing headers; am having problems with my
caml-list to nntp gateway.]

>: Jacques Garrigue

> To summarize recent posts by various people, there are two approaches
> for a universal mode:

You left without discussion the approach suggested by Arturo Borquez,
which is quite distinct from that by Chris Hecker:

"An unlabeled argument should be labeled with the first available label
in the declared type of the function being called."

(together with "every function argument declared without label is
given an implicit unique label sui generis"?)

Potential benefits:
* drop-in compatibility with both classic and label mode,
 for those who use consistently use either style.
* allows for continuous change between both styles, depending on what
 one prefers for the function being written.
* works well with fold and higher-order functions and currification.

Potential Problems:
* the order of the labels in the type matters, whereas it didn't,
 which implies compiler changes. I suppose the compiler must currently
 somehow handle order anyway, since even with a possible early canonical
 ordering of labels, you must handle functions that declare a varying
 subset of labels in the global pool.
* it may break either the equivalence between (f x) and (f ~1:x), or the way
 numerical labels do not commute with other labels.
* type declarations that change the order of labels now have some specialness
 in that they modify the meaning of positional parameters. This might be
 something some people would strongly dislike. Or maybe not.
* type inference is made more complex, because of the interaction between
 labelled and unlabelled arguments.

I admit I certainly don't have clear enough an idea of the problems to
judge how doable it is, but if this proposal is doable, it seems to me
that the benefits might be worth it, since it unifies classic and label modes.
In all cases, I'd like to hear about what you think of such proposal,
particularly so if you dismiss it. Let the fact that it was used in some
ancient macroassemblers not make you scorn it.

(I already tried to draw your attention to this approach in the same previous
message when I suggested that a classic mode stdlib could be obtained from
a labelled mode one by writing a camlp4 metaprogram that strips labels and
dumps a wrapper library).

[ François-René DVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ]
[  TUNES project for a Free Reflective Computing System  | http://tunes.org  ]
The ancients stole all our ideas from us. -- Mark Twain
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 53+ messages in thread
* RE: [Caml-list] Future of labels, and ideas for library labelling
@ 2001-04-04 16:37 Dave Berry
  0 siblings, 0 replies; 53+ messages in thread
From: Dave Berry @ 2001-04-04 16:37 UTC (permalink / raw)
  To: Jacques Garrigue, patrick; +Cc: caml-list

> -----Original Message-----
> From: Jacques Garrigue [mailto:garrigue@kurims.kyoto-u.ac.jp]
> ...
> SML for instance has structural
> records, and uses them in its basis library. You can look at 
> the result for yourself. For me it's only half the way.
> * You cannot mix labeled and unlabeled arguments, whereas you often
>   want to keep one unlabeled argument in your function.

As you say, this is a matter of taste, but I don't agree with your
sentiment here.  I would prefer all labels or none, rather than having
to remember which arguments have labels and which don't.

Better still is the suggestion of Arturo Borquez and Dave Mason, where
labels can be given or not, as the caller pleases.  My only reservation
is that I don't know how easy this would be to extend to optional
arguments.

> * I believe labels + currying give a nicer syntax.

It's a matter of taste again, but I think the OCaml label syntax is
awful.  I also don't like curried syntax: with f{x=0, y=1} or f(0, 1),
the brackets clearly delineate the arguments.  Curried syntax makes this
much less clear (particularly when mixed with infix operators).  I find
most Haskell programs unreadable for this reason.
(To be fair, I think much of SML's syntax is also awful).

> * You would of course have to extends records with optional fields,
>   with creates new problems of overloading.

This is certainly true.  Possibly we could simplify the problem by only
allowing optional arguments in records used as parameter lists.

> >  1.  List.fold_right (List.fold_right IntSet.add) lists IntSet.empty

> Now let's write it with labels
>    List.fold_left lists ~init:IntSet.empty
>      ~f:(fun set l ->
>            List.fold_left l ~init:set ~f:(fun set x -> 
> IntSet.add x set))

or:

>    List.fold_left lists ~acc:IntSet.empty
>      ~f:(List.fold_left ~f:(fun ~acc item -> IntSet.add acc ~item))

> Now, which is the more readable program, this one or yours.

This is taste again, but I'm tempted to ask "Are you serious"???
Patrick's version is clearly more readable.  Better still would be to
get rid of some qualified names and use more concise names:

  foldr (foldr IntSet.add) lists IntSet.empty

Brevity can make programs easier to read.


> For me it was really revealing to hear
> from program transformation researchers in Haskell (who use fold for
> their transformations) that they didn't use it directly in actual
> programs.

That's potentially interesting, but did you ask what they used instead?
Maybe they used list comprehensions or monad syntax.

Dave.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 53+ messages in thread
* Re: [Caml-list] Future of labels, and ideas for library labelling
@ 2001-04-03 16:39 John R Harrison
  0 siblings, 0 replies; 53+ messages in thread
From: John R Harrison @ 2001-04-03 16:39 UTC (permalink / raw)
  To: caml-list; +Cc: John Harrison


Like Jean-Christophe Filliatre and Josh Guttman, I'm one of the "silent
majority" who are happy with conventional CAML syntax and have no
inclination to use labels. I can well imagine that labels might provide
valuable documentation in certain situations, but I put more value on the
directness and mathematical elegance of the traditional functional style.

I'm all in favour of OCaml being an exciting vehicle for new programming
language research. This may be partly responsible for its present vitality.
But it's important to remember that some of us were attracted to CAML by
its conceptual simplicity and its efficient and economical implementation,
rather than by any exotic experimental features. So I fully support
Xavier's policy of keeping extensions like labels out of the "core"
language.

Cheers,

John.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 53+ messages in thread
* Re: [Caml-list] Future of labels
@ 2001-03-31  3:40 Yaron M. Minsky
  2001-04-02  3:39 ` [Caml-list] Future of labels, and ideas for library labelling Jacques Garrigue
  0 siblings, 1 reply; 53+ messages in thread
From: Yaron M. Minsky @ 2001-03-31  3:40 UTC (permalink / raw)
  To: caml-list

I make heavy use of labels in classic mode both for the
extra type safety it provides and for documentation.  I
find it to be extremely useful, and would be sad to see
classic mode go. I've never felt a great need for commuting
of non-optional arguments.  LablTk, at least, seemed quite
usable in classic mode.

The idea of stripping labels out of the standard library
seems like a mistake.  The main thing I like about labels
is the extra safety they provide.  For example, the ~key
and ~data labels for the function in Map's iter is very
useful, particularly when the key and data happen to be the
same type.

I agree that having ocaml have one standard mode would be
best, if possible.  If there continue to be two modes, I am
strongly in favor of a pragma for specifying the mode on a
file-by-file basis.

I guess my ideal solution would be to have classic mode (or
some sound version of it) be the standard.  I see no great
value in commuting labels for non-optional arguments
(though I understand many disagree) and allowing novices to
ignore labels alltogether is enormously important --- ML is
weird enough for someone schooled in imperative languages,
without needing to understand labels as well.

(On another note, it would be lovely if one of these days
ocaml could move to something like the alternative syntax
shipped with camlp4.  There are a number of bits of the
caml syntax that are quite counterintuitive, most of which
are fixed with the alternative syntax.)

y

-- 
|--------/            Yaron M. Minsky              \--------|
|--------\ http://www.cs.cornell.edu/home/yminsky/ /--------|

OpenPGP Key at http://keyserver.pgp.com - KeyID 0x91F2C47C
Key Fingerprint:
   6838 FF4E 256C BD24 453E 6EEA 0FBE 6CF8 91F2 C47C
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2001-04-17 18:10 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-03  7:27 [Caml-list] Future of labels, and ideas for library labelling Arturo Borquez
  -- strict thread matches above, loose matches on Subject: below --
2001-04-17 11:53 Poigné
2001-04-11 10:48 Francois-Rene Rideau
2001-04-04 16:37 Dave Berry
2001-04-03 16:39 John R Harrison
2001-03-31  3:40 [Caml-list] Future of labels Yaron M. Minsky
2001-04-02  3:39 ` [Caml-list] Future of labels, and ideas for library labelling Jacques Garrigue
2001-04-02  7:58   ` Judicael Courant
2001-04-02  8:50     ` Markus Mottl
2001-04-02 10:33     ` kahl
2001-04-03  0:35       ` Jacques Garrigue
2001-04-03  1:36         ` Kipton M Barros
2001-04-03  1:52         ` Patrick M Doane
2001-04-03  3:53           ` Jacques Garrigue
2001-04-03  5:10             ` Patrick M Doane
2001-04-03  9:30               ` Jacques Garrigue
2001-04-03  8:52             ` Xavier Leroy
2001-04-03  9:34               ` Judicael Courant
2001-04-03  9:54               ` Jacques Garrigue
2001-04-03 12:59                 ` Jean-Christophe Filliatre
2001-04-03 14:06                   ` Jacques Garrigue
2001-04-03 14:12                     ` Daniel de Rauglaudre
2001-04-03 14:42                       ` Claude Marche
2001-04-04 19:18                     ` Gerd Stolpmann
2001-04-03  9:55               ` Ohad Rodeh
2001-04-03 12:02               ` Dave Mason
2001-04-03 13:43               ` Francois-Rene Rideau
2001-04-03 14:23                 ` Daniel de Rauglaudre
2001-04-03 13:43               ` Frank Atanassow
2001-04-03 13:58               ` Joshua D. Guttman
2001-04-03 16:52               ` Eric C. Cooper
2001-04-09  9:05                 ` John Max Skaller
2001-04-09  7:29             ` John Max Skaller
2001-04-03  8:07         ` Judicael Courant
2001-04-03  6:55     ` Chris Hecker
2001-04-09  8:11       ` John Max Skaller
2001-04-09  9:21         ` Jacques Garrigue
2001-04-09 15:06           ` Fergus Henderson
2001-04-10 18:49           ` John Max Skaller
2001-04-09 19:54         ` Chris Hecker
2001-04-10  3:37           ` Jacques Garrigue
2001-04-10  7:42             ` Judicael Courant
2001-04-10  8:25               ` Jacques Garrigue
2001-04-10  8:46               ` Claude Marche
2001-04-10 10:09                 ` Jacques Garrigue
2001-04-10 14:42                   ` Lionnel Maugis
2001-04-10  9:06             ` François-René Rideau
2001-04-11 15:34               ` Jacques Garrigue
2001-04-11 17:48                 ` Dave Mason
2001-04-10 22:43             ` Brian Rogoff
2001-04-11  8:29               ` Jacques Garrigue
2001-04-11  9:44                 ` Anton Moscal
2001-04-11 13:16                 ` Didier Remy
2001-04-11 15:11                   ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).