caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Calling a function with a self-defined type as argument
@ 2002-08-22  1:11 Oliver Bandel
  2002-08-22  1:43 ` SooHyoung Oh
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Oliver Bandel @ 2002-08-22  1:11 UTC (permalink / raw)
  To: caml-list

Hello,

after rewriting a perl-program into Ocaml,
I tried it in different ways.
After getting a minimal working-version ready,
I tried some OO-stuff today first time in Ocaml.
That's nice. I like it. Normally OO is annoying,
but in OCaml, it's really fun. :)

But during rewriting the program, I saw that
I could do some advantages in using own types.
I had tried it before, but had no success
with using  "try ...with ..."  and the self
defined type.

But today I had better Ideas and so I started
concentrating on working with the type, and
after that maybe add some OO-stuff (if necessary/
helpful).

During experimenting with the type, I experienced a
- for me - strange behaviour. You can see my questions
in the last lines of the code (see below).


If you have other comments (optimizing code, better indenting-style),
please let me know.

(The program-code is not complete, here; only the necessary
stuff for showing my question is in this mail.)

###########################################################################
###########################################################################
###########################################################################
let suchstring = if Array.length Sys.argv > 1 then Sys.argv.(1) else ""

let inch = open_in "de-tex-faq.txt"  (* where to read from (inch: in-channel) *)

type contents =   EMPTY
                | Line of string
                | Empty_Line
                | EOF

type inputline = { mutable line: contents; mutable lastline: contents }

let il = { line = EMPTY; lastline = EMPTY }  (* il: inputline *)



(* rl: read line *)

let rl channel =
  let content = try Line(input_line channel) with
                 | _ -> EOF
     in
      let res content = match content with
       | Line ("")  -> Empty_Line
       | l   -> l                  (* should match all other stuff *)
       in
         il.lastline <- il.line;
         il.line <- content


let x y = match y with
  | EOF        -> print_string "EOF!!\n"
  | Empty_Line -> print_string "Empty_Line!!\n"
  | EMPTY      -> print_string "unexpected EMPTY-case!\n"
  | Line txt   -> print_string txt

(* yes, "x" is a stupid name, but it was only a test until now. *)


let _ = x Empty_Line;;   (* expected behaviour *)
let _ = x EOF;;          (* expected behaviour *)
let _ = x EMPTY;;        (* expected behaviour *)

(*
   let _ = x Line "h0oifdaji oi" ;;
   This last one does not work: => "This function is applied to too many arguments"

   let _ = x Line( "reuruhjf" ) ;;
   This last one does not work: => "This function is applied to too many arguments"

   But it works in this way:
   let _ = x (Line "reuruhjf") ;;

   WHY?         (why *only* that?)
  
   At least the second example (with parantheses around the
   Line's arguments) should work...?!  
*)

###########################################################################
###########################################################################
###########################################################################



Ciao,
   Oliver

P.S.: I love that language. It's really fine :)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  1:11 [Caml-list] Calling a function with a self-defined type as argument Oliver Bandel
@ 2002-08-22  1:43 ` SooHyoung Oh
  2002-08-22  1:50 ` Oleg
  2002-08-22  2:04 ` Dimitri Ara
  2 siblings, 0 replies; 14+ messages in thread
From: SooHyoung Oh @ 2002-08-22  1:43 UTC (permalink / raw)
  To: Oliver Bandel, caml-list


>
> (*
>    let _ = x Line "h0oifdaji oi" ;;
>    This last one does not work: => "This function is applied to too many
arguments"
>

"x" expects only one argument, but it has 2.

>    let _ = x Line( "reuruhjf" ) ;;
>    This last one does not work: => "This function is applied to too many
arguments"
>

Same as the first one. In this example, () has no effect.
In most cases, "a(b)" is the same meaning as "a b" in Ocaml.

>    But it works in this way:
>    let _ = x (Line "reuruhjf") ;;
>
>    WHY?         (why *only* that?)
>

"x" is applied to one argument.

>    At least the second example (with parantheses around the
>    Line's arguments) should work...?!
> *)

---
SooHyoung Oh
tel: 02)583-8709, 042)861-8649
cell. phone: 011-453-4303
web: http://www.duonix.com


-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  1:11 [Caml-list] Calling a function with a self-defined type as argument Oliver Bandel
  2002-08-22  1:43 ` SooHyoung Oh
@ 2002-08-22  1:50 ` Oleg
  2002-08-22  2:20   ` Pal-Kristian Engstad
  2002-08-22 12:40   ` Oliver Bandel
  2002-08-22  2:04 ` Dimitri Ara
  2 siblings, 2 replies; 14+ messages in thread
From: Oleg @ 2002-08-22  1:50 UTC (permalink / raw)
  To: Oliver Bandel, caml-list

On Wednesday 21 August 2002 09:11 pm, Oliver Bandel wrote:


... because

> (*
>    let _ = x Line "h0oifdaji oi" ;;
>    This last one does not work: => "This function is applied to too many
> arguments"

x is applied to 2 arguments

>    let _ = x Line( "reuruhjf" ) ;;
>    This last one does not work: => "This function is applied to too many
> arguments"

still 2 (no difference whatsoever)

>    But it works in this way:
>    let _ = x (Line "reuruhjf") ;;

Now x is applied to 1 argument.

>    WHY?         (why *only* that?)
>  
>    At least the second example (with parantheses around the
>    Line's arguments) should work...?!  
> *)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  1:11 [Caml-list] Calling a function with a self-defined type as argument Oliver Bandel
  2002-08-22  1:43 ` SooHyoung Oh
  2002-08-22  1:50 ` Oleg
@ 2002-08-22  2:04 ` Dimitri Ara
  2002-08-22 12:47   ` Oliver Bandel
  2002-08-22 23:51   ` Pixel
  2 siblings, 2 replies; 14+ messages in thread
From: Dimitri Ara @ 2002-08-22  2:04 UTC (permalink / raw)
  To: caml-list

Oliver Bandel <oliver@first.in-berlin.de> a écrit :

> (*
>    let _ = x Line "h0oifdaji oi" ;;
>    This last one does not work: => "This function is applied to too many arguments"
> 
>    let _ = x Line( "reuruhjf" ) ;;
>    This last one does not work: => "This function is applied to too many arguments"
> 
>    But it works in this way:
>    let _ = x (Line "reuruhjf") ;;
> 
>    WHY?         (why *only* that?)
>   
>    At least the second example (with parantheses around the
>    Line's arguments) should work...?!  
> *)

Because :

(1) application is left associative.

Thus `f x y' means `(f x) y' and
     `x Line ""' means `(x Line) ""'.

(2) parentheses don't delimit the arguments of a function or a
    constructor but only fix the precedence of an expression.

Thus f x (y) means f x y and
     `x Line ("")' means `x Line ""'.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  1:50 ` Oleg
@ 2002-08-22  2:20   ` Pal-Kristian Engstad
  2002-08-22  2:32     ` Dimitri Ara
  2002-08-22 12:40   ` Oliver Bandel
  1 sibling, 1 reply; 14+ messages in thread
From: Pal-Kristian Engstad @ 2002-08-22  2:20 UTC (permalink / raw)
  To: Oleg, Oliver Bandel, caml-list

Hi,

I don't know if it is in the FAQ, but a more interesting question is why the 
compiler cannot deduce the correct type without us having to type in 
parenthesis, at least in cases where there can be no ambiguity.

I.e.:

let addone x = x + 1
let double x = x * x

let f x = addone double x     (*** Should the compiler not deduce this? ***)
let g = addone double         (*** Is this why? ***)

PKE.

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  2:20   ` Pal-Kristian Engstad
@ 2002-08-22  2:32     ` Dimitri Ara
  0 siblings, 0 replies; 14+ messages in thread
From: Dimitri Ara @ 2002-08-22  2:32 UTC (permalink / raw)
  To: Pal-Kristian Engstad; +Cc: Oleg, Oliver Bandel, caml-list

Pal-Kristian Engstad <engstad@naughtydog.com> a écrit :

> Hi,
> 
> I don't know if it is in the FAQ, but a more interesting question is why the 
> compiler cannot deduce the correct type without us having to type in 
> parenthesis, at least in cases where there can be no ambiguity.
> 
> I.e.:
> 
> let addone x = x + 1
> let double x = x * x
> 
> let f x = addone double x     (*** Should the compiler not deduce this? ***)
> let g = addone double         (*** Is this why? ***)

In the general case it can't:

# let f g x = x;;
val f : 'a -> 'b -> 'b = <fun>
# let h x = x;;
val h : 'a -> 'a = <fun>
# (f h) 1;;
- : int = 1
# f (h 1);;
- : '_a -> '_a = <fun>

When there is no ambiguity it could but it would be
expensive, dangerous (because the compiler could find a way to type an
expression which is ill typed according to what you meant) and would
make the sources unreadable.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  1:50 ` Oleg
  2002-08-22  2:20   ` Pal-Kristian Engstad
@ 2002-08-22 12:40   ` Oliver Bandel
  2002-08-22 13:15     ` Markus Mottl
  1 sibling, 1 reply; 14+ messages in thread
From: Oliver Bandel @ 2002-08-22 12:40 UTC (permalink / raw)
  To: Oleg; +Cc: caml-list

On Wed, 21 Aug 2002, Oleg wrote:

> On Wednesday 21 August 2002 09:11 pm, Oliver Bandel wrote:
> 
> 
> ... because
> 
> > (*
> >    let _ = x Line "h0oifdaji oi" ;;
> >    This last one does not work: => "This function is applied to too many
> > arguments"
> 
> x is applied to 2 arguments
> 
> >    let _ = x Line( "reuruhjf" ) ;;
> >    This last one does not work: => "This function is applied to too many
> > arguments"
> 
> still 2 (no difference whatsoever)

But the Line ("text")-argument is only complete as a Line(),
if Line() has a higher priority than the function-call.
I have *one* argument, which is complete if given EMPTY,
and complete if given Line ("argument").

Shouldn't be types have a higher priority than calls
in this case?
Is Line() in this example handled like an ordinary function?

That is, what I think that it is a littlebid crazy.
I use the type-definition to put things together
nad use them as one type, but then it is handled
like a puzzle, before it is put together.
But I want here a complete picture, and I thought
the compiler would put the parts together: How to
put them together is clear: I have said it him in the
type-declaration.

Ciao,
   Oliver

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  2:04 ` Dimitri Ara
@ 2002-08-22 12:47   ` Oliver Bandel
  2002-08-22 13:13     ` Sven LUTHER
  2002-08-22 14:07     ` Remi VANICAT
  2002-08-22 23:51   ` Pixel
  1 sibling, 2 replies; 14+ messages in thread
From: Oliver Bandel @ 2002-08-22 12:47 UTC (permalink / raw)
  To: Dimitri Ara; +Cc: caml-list


On 22 Aug 2002, Dimitri Ara wrote:

> Oliver Bandel <oliver@first.in-berlin.de> a écrit :
> 
> > (*
> >    let _ = x Line "h0oifdaji oi" ;;
> >    This last one does not work: => "This function is applied to too many arguments"
> > 
> >    let _ = x Line( "reuruhjf" ) ;;
> >    This last one does not work: => "This function is applied to too many arguments"
> > 
> >    But it works in this way:
> >    let _ = x (Line "reuruhjf") ;;
> > 
> >    WHY?         (why *only* that?)
> >   
> >    At least the second example (with parantheses around the
> >    Line's arguments) should work...?!  
> > *)
> 
> Because :
> 
> (1) application is left associative.
> 
> Thus `f x y' means `(f x) y' and
>      `x Line ""' means `(x Line) ""'.
> 
> (2) parentheses don't delimit the arguments of a function or a
>     constructor but only fix the precedence of an expression.
> 
> Thus f x (y) means f x y and
>      `x Line ("")' means `x Line ""'.

OK.
But why has the Line()-argument not a higher pruiority than the
function-call?
The Line()-argument is only complete, if it get's it's
args. And the type-declaration says in detail, how to
handle the Line().

But it seems to me that it is handled like an "ordinary"
function call. I thought, that the compiler would put
this together: *one* argument to the function, and the
argument means using the type `Line "text"'.

Ciao,
   Oliver

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22 12:47   ` Oliver Bandel
@ 2002-08-22 13:13     ` Sven LUTHER
  2002-08-22 14:07     ` Remi VANICAT
  1 sibling, 0 replies; 14+ messages in thread
From: Sven LUTHER @ 2002-08-22 13:13 UTC (permalink / raw)
  To: Oliver Bandel; +Cc: Dimitri Ara, caml-list

On Thu, Aug 22, 2002 at 02:47:26PM +0200, Oliver Bandel wrote:
> 
> On 22 Aug 2002, Dimitri Ara wrote:
> 
> > Oliver Bandel <oliver@first.in-berlin.de> a écrit :
> > 
> > > (*
> > >    let _ = x Line "h0oifdaji oi" ;;
> > >    This last one does not work: => "This function is applied to too many arguments"
> > > 
> > >    let _ = x Line( "reuruhjf" ) ;;
> > >    This last one does not work: => "This function is applied to too many arguments"
> > > 
> > >    But it works in this way:
> > >    let _ = x (Line "reuruhjf") ;;
> > > 
> > >    WHY?         (why *only* that?)
> > >   
> > >    At least the second example (with parantheses around the
> > >    Line's arguments) should work...?!  
> > > *)
> > 
> > Because :
> > 
> > (1) application is left associative.
> > 
> > Thus `f x y' means `(f x) y' and
> >      `x Line ""' means `(x Line) ""'.
> > 
> > (2) parentheses don't delimit the arguments of a function or a
> >     constructor but only fix the precedence of an expression.
> > 
> > Thus f x (y) means f x y and
> >      `x Line ("")' means `x Line ""'.
> 
> OK.
> But why has the Line()-argument not a higher pruiority than the
> function-call?
> The Line()-argument is only complete, if it get's it's
> args. And the type-declaration says in detail, how to
> handle the Line().

No, in ocaml, the function application is the space ' ', so what you are
used to write "f(x)", is just plain "f x", and you can add a few ( to
make unambigous, as in your case : (f x).

It seems confusing if you are not used to it, but makes for more clearer code.

Friendly,

Sven Luther
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22 12:40   ` Oliver Bandel
@ 2002-08-22 13:15     ` Markus Mottl
  2002-08-22 20:40       ` Oliver Bandel
  0 siblings, 1 reply; 14+ messages in thread
From: Markus Mottl @ 2002-08-22 13:15 UTC (permalink / raw)
  To: Oliver Bandel; +Cc: Oleg, caml-list

Oliver Bandel schrieb am Thursday, den 22. August 2002:
> But the Line ("text")-argument is only complete as a Line(),
> if Line() has a higher priority than the function-call.
> I have *one* argument, which is complete if given EMPTY,
> and complete if given Line ("argument").

The parser attempts to parse arguments of a function call, all of
which must be expressions. "Line" is not an expression, it's just a
data constructor. To disambiguate things, you have to use parentheses.
Note that your proposal that the compiler should use type definitions
to see how many arguments constructors take would make sources really
unreadable for humans.  Things are perfect as they are.

> Shouldn't be types have a higher priority than calls
> in this case?

"Line" is not a type but a data constructor. It just allows you to
discriminate between values.

> Is Line() in this example handled like an ordinary function?

Even if it were a function, you'd still need parentheses, otherwise you'd
get into troubles with partial function applications, which sometimes
need disambiguation, because the semantics wouldn't be necessarily clear.

> But I want here a complete picture, and I thought
> the compiler would put the parts together: How to
> put them together is clear: I have said it him in the
> type-declaration.

It may be clear here but not always. Even if things can be tractably
analyzed by an intelligent compiler, you still need to enforce readability
of sources. It would be absolute hell to let people parse such programs,
because they'd constantly have to look up type definitions in other
places to parse things correctly. Not a problem for a compiler - huge
problem for humans!

LG,
Markus

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22 12:47   ` Oliver Bandel
  2002-08-22 13:13     ` Sven LUTHER
@ 2002-08-22 14:07     ` Remi VANICAT
  2002-08-22 14:15       ` Markus Mottl
  1 sibling, 1 reply; 14+ messages in thread
From: Remi VANICAT @ 2002-08-22 14:07 UTC (permalink / raw)
  To: caml-list

Oliver Bandel <oliver@first.in-berlin.de> writes:

> On 22 Aug 2002, Dimitri Ara wrote:
>
>> Thus f x (y) means f x y and
>>      `x Line ("")' means `x Line ""'.
>
> OK.
> But why has the Line()-argument not a higher pruiority than the
> function-call?
> The Line()-argument is only complete, if it get's it's
> args. And the type-declaration says in detail, how to
> handle the Line().

Well, imagine that the compiler do what you want, and imagine that you
have to read a code coding from someone using strange name.

then when you read a code like :

x Azerty ""

you won't know if it is 
x (Azerty "")
or 
(x Azerty) ""
without reading the declaration of Azerty.

Thanks to the way the language (and compiler) actually work, I can say
that it is the first solution, even if I don't know what is this
Azerty constructor.

-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22 14:07     ` Remi VANICAT
@ 2002-08-22 14:15       ` Markus Mottl
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Mottl @ 2002-08-22 14:15 UTC (permalink / raw)
  To: Remi VANICAT; +Cc: caml-list

On Thu, 22 Aug 2002, Remi VANICAT wrote:
> then when you read a code like :
> 
> x Azerty ""
> 
> you won't know if it is 
> x (Azerty "")
> or 
> (x Azerty) ""
> without reading the declaration of Azerty.
> 
> Thanks to the way the language (and compiler) actually work, I can say
> that it is the first solution, even if I don't know what is this
> Azerty constructor.

I suppose you meant the second solution... ;-)

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22 13:15     ` Markus Mottl
@ 2002-08-22 20:40       ` Oliver Bandel
  0 siblings, 0 replies; 14+ messages in thread
From: Oliver Bandel @ 2002-08-22 20:40 UTC (permalink / raw)
  To: Markus Mottl; +Cc: Oleg, caml-list

Hello Markus,

On Thu, 22 Aug 2002, Markus Mottl wrote:

> Oliver Bandel schrieb am Thursday, den 22. August 2002:
> > But the Line ("text")-argument is only complete as a Line(),
> > if Line() has a higher priority than the function-call.
> > I have *one* argument, which is complete if given EMPTY,
> > and complete if given Line ("argument").
> 
> The parser attempts to parse arguments of a function call, all of
> which must be expressions. "Line" is not an expression, it's just a
> data constructor. To disambiguate things, you have to use parentheses.
> Note that your proposal that the compiler should use type definitions
> to see how many arguments constructors take would make sources really
> unreadable for humans.  Things are perfect as they are.

OK, I believe it you.
I'm the beginner in Ocaml, not you. ;-)

I have to program more in Ocaml, then I will see
how it works.

After looking again on my sources (the one I mailed to the list)
I found some other things, I could do better, e.g. not use
Empty_Line for Line "", because it does not help much, but
yields some problems.

All in all I see, that I have some problems with Ocaml,
because I have not used it very often.

But even after this short time of using functional programming
(I looked a littlebid into it and then made a pause, looked
again in and made a pause) I'm very annoyed, when I use imperative
programming.
E.G. the reading of the lines and comparing them with my
ad-hoc parsing is really annoying, especially, when I
want to put the read text into an array of strings or
array of objects...

...when programming in the usual C-like style, I'm now
constantly annoyed.

I will try some more functional ideas and use recursion
instead of loops. I hope that helps.



[...]
> It may be clear here but not always. Even if things can be tractably
> analyzed by an intelligent compiler, you still need to enforce readability
> of sources. It would be absolute hell to let people parse such programs,
> because they'd constantly have to look up type definitions in other
> places to parse things correctly. Not a problem for a compiler - huge
> problem for humans!

OK.

I maybe one day will see the advantages. ;-)

Ciao,
   Oliver

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

* Re: [Caml-list] Calling a function with a self-defined type as argument
  2002-08-22  2:04 ` Dimitri Ara
  2002-08-22 12:47   ` Oliver Bandel
@ 2002-08-22 23:51   ` Pixel
  1 sibling, 0 replies; 14+ messages in thread
From: Pixel @ 2002-08-22 23:51 UTC (permalink / raw)
  To: Dimitri Ara; +Cc: caml-list

Dimitri Ara <dimitri@nerim.net> writes:

> >    let _ = x Line( "reuruhjf" ) ;;
> >    This last one does not work: => "This function is applied to too many arguments"

has it been considered adding a syntactical rule disallowing/warning

  expr1 expr2( ... )

when there is no space better "expr2" and "(" ?? 
This exception in the syntax may be ugly, but useful!


or is this syntax used? at least not in the code I tested 
(including ocaml source):

% perl -ne 'print "$ARGV: $_" if /(\w+)\s+\w+\(/ && $1 !~ /^(let|with|in|if|then|else|match|function|try|do|module|begin)$/' `find -name "*.ml"`
... (only matching lines are comments)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


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

end of thread, other threads:[~2002-08-22 23:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-22  1:11 [Caml-list] Calling a function with a self-defined type as argument Oliver Bandel
2002-08-22  1:43 ` SooHyoung Oh
2002-08-22  1:50 ` Oleg
2002-08-22  2:20   ` Pal-Kristian Engstad
2002-08-22  2:32     ` Dimitri Ara
2002-08-22 12:40   ` Oliver Bandel
2002-08-22 13:15     ` Markus Mottl
2002-08-22 20:40       ` Oliver Bandel
2002-08-22  2:04 ` Dimitri Ara
2002-08-22 12:47   ` Oliver Bandel
2002-08-22 13:13     ` Sven LUTHER
2002-08-22 14:07     ` Remi VANICAT
2002-08-22 14:15       ` Markus Mottl
2002-08-22 23:51   ` Pixel

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).