caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pattern matching and strings
@ 2002-10-02 14:12 Alessandro Baretta
  2002-10-02 15:02 ` Luc Maranget
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-02 14:12 UTC (permalink / raw)
  To: Ocaml

I have to do a little bit of pattern matching on strings. My 
first instict was to write something like the following.

let foo x = ...
let bar x = ...
... = function
| "foo" ^ rest -> foo rest
| "bar" ^ rest -> bar rest
| _ -> raise Unrecognized

Of course, this is not possible because (^) is an operator 
rather than a constructor. Since I believe that the above 
code is much more natural and idiomatic than code based on 
regexps, I wonder how much compiler magic it would take to 
make it work. Probably all it takes is some syntax-magic 
since the above can be mapped onto the following:

open Scanf

... = function x -> begin
   try sscanf x "foo%[^]" foo with Scan_failure _ ->
   try sscanf x "bar%[^]" bar with Scan_failure _ ->
     raise Unrecognized
end

An equivalent mapping could be done with the Str library or 
any other regexp library.

However, the former is much cleaner. If it could be had, I'd 
appreciate it.

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-02 14:12 [Caml-list] Pattern matching and strings Alessandro Baretta
@ 2002-10-02 15:02 ` Luc Maranget
  2002-10-02 16:21   ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
  2002-10-02 20:59 ` [Caml-list] views for strings (was: Pattern matching and strings) Chris Hecker
  2002-10-03  8:31 ` [Caml-list] Pattern matching and strings Sven Luther
  2 siblings, 1 reply; 32+ messages in thread
From: Luc Maranget @ 2002-10-02 15:02 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml

> 
> I have to do a little bit of pattern matching on strings. My 
> first instict was to write something like the following.
> 
> let foo x = ...
> let bar x = ...
> ... = function
> | "foo" ^ rest -> foo rest
> | "bar" ^ rest -> bar rest
> | _ -> raise Unrecognized
> 
> Of course, this is not possible because (^) is an operator 
> rather than a constructor. Since I believe that the above 
> code is much more natural and idiomatic than code based on 
> regexps, I wonder how much compiler magic it would take to 
> make it work. Probably all it takes is some syntax-magic 
> since the above can be mapped onto the following:

Hum, I am not found of such an idea. As you tell yoursef,  ``(^)  is
an operator rather than a  constructor''. Making a special case for
(^) is a bad idea from the start.
The special thing about a pattern is that is contains constructors,
variables, (and constants) and nothing else.
This restriction allows efficient
compilation and lots of static checks in some uniform framework.
Getting out of the uniform framework is a risk
(cf. n+k patterns in Haskell eg).

> 
> open Scanf
> 
> ... = function x -> begin
>    try sscanf x "foo%[^]" foo with Scan_failure _ ->
>    try sscanf x "bar%[^]" bar with Scan_failure _ ->
>      raise Unrecognized
> end
> 
you mean

 ... = function x -> begin
    try sscanf x "foo%s" foo with Scan_failure _ ->
    try sscanf x "bar%s" bar with Scan_failure _ ->
      raise Unrecognized
 end



> An equivalent mapping could be done with the Str library or 
> any other regexp library.
Those libs are optional.... (at present).

I agree, having some kind of fusion between ML pattern-matching and
regexp-matching is an issue, there is research work on this.
But this means lot of work...

> 
> Alex


--Luc 


-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-02 15:02 ` Luc Maranget
@ 2002-10-02 16:21   ` Alessandro Baretta
  2002-10-02 17:15     ` Luc Maranget
  2002-10-04  9:07     ` Pierre Weis
  0 siblings, 2 replies; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-02 16:21 UTC (permalink / raw)
  To: Luc Maranget, Ocaml


Luc Maranget wrote:
> Hum, I am not found of such an idea. As you tell yoursef,  ``(^)  is
> an operator rather than a  constructor''. Making a special case for
> (^) is a bad idea from the start.
> The special thing about a pattern is that is contains constructors,
> variables, (and constants) and nothing else.
> This restriction allows efficient
> compilation and lots of static checks in some uniform framework.
> Getting out of the uniform framework is a risk
> (cf. n+k patterns in Haskell eg).

I realize this, but I also believe that pattern matching on 
strings is something that would make string-processing code 
much clearer and more concise. I don't mean that we have to 
use perforce the same "function" and "match" constructs that 
we use for "ordinary" pattern matching, yet some form of 
pattern matching over strings would be helpful.

> 
>>open Scanf
>>
>>... = function x -> begin
>>   try sscanf x "foo%[^]" foo with Scan_failure _ ->
>>   try sscanf x "bar%[^]" bar with Scan_failure _ ->
>>     raise Unrecognized
>>end
>>
> 
> you mean
> 
>  ... = function x -> begin
>     try sscanf x "foo%s" foo with Scan_failure _ ->
>     try sscanf x "bar%s" bar with Scan_failure _ ->
>       raise Unrecognized
>  end

I meant what I wrote. The %s conversion stops reading at the 
  first whitespace character. However, ocaml does not like 
the  "%[^]" which, in my opinion, is to be considered a 
mini-bug. "%[^]" should be interpreted as "the set of all 
characters except none", which is "the set of all 
characters", which can also be expressed, more verbosely, as 
"%[\000-\255]". By the same standards, "%[]" is rejected, 
when it should be interpreted as "the set containing no 
characters", or more verbosely "%[^\000-\255]"


> 
> 
>>An equivalent mapping could be done with the Str library or 
>>any other regexp library.
> 
> Those libs are optional.... (at present).
> 
> I agree, having some kind of fusion between ML pattern-matching and
> regexp-matching is an issue, there is research work on this.
> But this means lot of work...
> 
> --Luc

Do you know of any literature on the subject which I might 
give a look at?

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-02 16:21   ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
@ 2002-10-02 17:15     ` Luc Maranget
  2002-10-02 18:30       ` Alessandro Baretta
  2002-10-04 13:01       ` Florian Douetteau
  2002-10-04  9:07     ` Pierre Weis
  1 sibling, 2 replies; 32+ messages in thread
From: Luc Maranget @ 2002-10-02 17:15 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Luc Maranget, Ocaml

> I realize this, but I also believe that pattern matching on 
> strings is something that would make string-processing code 
> much clearer and more concise. I don't mean that we have to 
> use perforce the same "function" and "match" constructs that 
> we use for "ordinary" pattern matching, yet some form of 
> pattern matching over strings would be helpful.

Ok, but again, I object to adding just one special case,
some uniform treatement is required here, and it looks difficult.



> I meant what I wrote. The %s conversion stops reading at the 
>   first whitespace character. However, ocaml does not like 
> the  "%[^]" which, in my opinion, is to be considered a 
> mini-bug. "%[^]" should be interpreted as "the set of all 
> characters except none", which is "the set of all 
> characters", which can also be expressed, more verbosely, as 
> "%[\000-\255]". By the same standards, "%[]" is rejected, 
> when it should be interpreted as "the set containing no 
> characters", or more verbosely "%[^\000-\255]"
Ok, those empty character sets should probably be considered...




> Do you know of any literature on the subject which I might 
> give a look at?

Yes, in
http://www.cis.upenn.edu/~bcpierce/

You can have a look at the papers on XDuce.
I was thinking of these papers, note that this might be an overkill...



Luc
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-02 17:15     ` Luc Maranget
@ 2002-10-02 18:30       ` Alessandro Baretta
  2002-10-02 18:32         ` Benjamin C. Pierce
  2002-10-04 13:01       ` Florian Douetteau
  1 sibling, 1 reply; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-02 18:30 UTC (permalink / raw)
  To: Luc Maranget; +Cc: Ocaml



Luc Maranget wrote:
> 
> 
>>Do you know of any literature on the subject which I might 
>>give a look at?
> 
> 
> Yes, in
> http://www.cis.upenn.edu/~bcpierce/
> 
> You can have a look at the papers on XDuce.
> I was thinking of these papers, note that this might be an overkill...
> 
> 
> 
> Luc

Ok. Thanks.

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-02 18:30       ` Alessandro Baretta
@ 2002-10-02 18:32         ` Benjamin C. Pierce
  0 siblings, 0 replies; 32+ messages in thread
From: Benjamin C. Pierce @ 2002-10-02 18:32 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Luc Maranget, Ocaml

> >>Do you know of any literature on the subject which I might 
> >>give a look at?
> > 
> > Yes, in
> > http://www.cis.upenn.edu/~bcpierce/
> > 
> > You can have a look at the papers on XDuce.

... Especially this one:

    http://www.cis.upenn.edu/~bcpierce/papers/regobj.ps

Another source -- even more relevant to this discussion -- is here:
   
    http://web.yl.is.s.u-tokyo.ac.jp/~sumii/pub/xperl.pdf

      -- B

-----------------------------------------------------------------------------
BENJAMIN C. PIERCE, Professor
Dept. of Computer & Information Science                bcpierce@cis.upenn.edu
University of Pennsylvania                                    +1 215 898-2012
200 South 33rd St.                                       Fax: +1 215 898-0587
Philadelphia, PA 19104, USA                http://www.cis.upenn.edu/~bcpierce
-----------------------------------------------------------------------------
-------------------
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] 32+ messages in thread

* [Caml-list] views for strings (was: Pattern matching and strings)
  2002-10-02 14:12 [Caml-list] Pattern matching and strings Alessandro Baretta
  2002-10-02 15:02 ` Luc Maranget
@ 2002-10-02 20:59 ` Chris Hecker
  2002-10-02 23:09   ` [Caml-list] " Alessandro Baretta
  2002-10-03  8:31 ` [Caml-list] Pattern matching and strings Sven Luther
  2 siblings, 1 reply; 32+ messages in thread
From: Chris Hecker @ 2002-10-02 20:59 UTC (permalink / raw)
  To: Alessandro Baretta, Ocaml


>take to make it work. Probably all it takes is some syntax-magic since the 
>above can be mapped onto the following:

I'm wondering if you couldn't do something with views rather than hacking 
enhanced string matching into caml.

http://citeseer.nj.nec.com/okasaki98view.html
http://groups.google.com/groups?th=a59b2a184f8b8b40

I would much rather have a powerful general feature like Views where you 
could make these string matches somewhat cleaner, than have a hacked-in 
perl-esque regex system that isn't useful if you aren't doing string stuff.

But, having said that, I'm not sure how you'd do your example with 
views.  Even relaxing the "evaluate each view transform once and memoize" 
rule, I can't see how to specify the string prefix to the view transform:

>let foo x = ...
>let bar x = ...
>... = function
>| "foo" ^ rest -> foo rest
>| "bar" ^ rest -> bar rest
>| _ -> raise Unrecognized

Using Okasaki's viewtype syntax, I think you'd want to do something like this:

viewtype string = Prefix of string * string | NoPrefix

match s with
   Prefix("foo",rest) -> foo rest
| Prefix("bar",rest) -> bar rest
| _ -> raise Unrecognized

But the problem is that the parameter to the view transform is just the 
string s, so you can't get the "foo" to it to know whether it's a 
prefix.  You could do

viewtype string * string = Prefix | NoPrefix

But then you'd have to specify the prefix in the match expression, which 
would be useless since there is more than one prefix you're looking 
for.  You could do

viewtype (string list) * string = Prefix of string * string

and pre-specify all the prefixes, but that's totally stupid and useless.  :)

It seems like the view transformation only uses information in one 
direction, from the match expression to a constructor, but it can't get 
information from the available constructors to see if they're possible 
matches.  There's no feedback.

So, maybe views can't make this cleaner, or maybe I just don't know enough 
about them.  Perhaps somebody who's thought about it more could say.

Chris

-------------------
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] 32+ messages in thread

* [Caml-list] Re: views for strings (was: Pattern matching and strings)
  2002-10-02 20:59 ` [Caml-list] views for strings (was: Pattern matching and strings) Chris Hecker
@ 2002-10-02 23:09   ` Alessandro Baretta
  0 siblings, 0 replies; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-02 23:09 UTC (permalink / raw)
  To: Chris Hecker, ocaml



Chris Hecker wrote:
> 
>> take to make it work. Probably all it takes is some syntax-magic since 
>> the above can be mapped onto the following:
> 
> 
> I'm wondering if you couldn't do something with views rather than 
> hacking enhanced string matching into caml.
> 

Views are an interesting idea. I had not thought about it. I 
have to look into this, although, as you pointed out, they 
are probably not what I'm looking for.

I want to point out that I think this string thing is not 
vital to Ocaml. The various regexp libraries amount to more 
than is necessary for any string processing task. I'd just 
like to have a more Camlesque way of dealing with strings 
than what is offered by regexps and the like.

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-02 14:12 [Caml-list] Pattern matching and strings Alessandro Baretta
  2002-10-02 15:02 ` Luc Maranget
  2002-10-02 20:59 ` [Caml-list] views for strings (was: Pattern matching and strings) Chris Hecker
@ 2002-10-03  8:31 ` Sven Luther
  2002-10-04 12:00   ` Andreas Rossberg
  2 siblings, 1 reply; 32+ messages in thread
From: Sven Luther @ 2002-10-03  8:31 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: Ocaml

On Wed, Oct 02, 2002 at 04:12:34PM +0200, Alessandro Baretta wrote:
> I have to do a little bit of pattern matching on strings. My 
> first instict was to write something like the following.
> 
> let foo x = ...
> let bar x = ...
> ... = function
> | "foo" ^ rest -> foo rest
> | "bar" ^ rest -> bar rest
> | _ -> raise Unrecognized

What about :

... = function
  | str when String.sub str 0 3 = "foo" -> foo (String.sub str 2 (String.length str - 3))
  | str when String.sub str 0 3 = "bar" -> bar (String.sub str 2 (String.length str - 3))
  | _ -> raise Unrecognized

Sure, this code is not very optimal, i guess you could write a nicer
function which will test the string incrementally using just String.get
or something such, but i suppose it will do the thing you want.

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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-02 16:21   ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
  2002-10-02 17:15     ` Luc Maranget
@ 2002-10-04  9:07     ` Pierre Weis
  2002-10-04  9:31       ` Alessandro Baretta
  1 sibling, 1 reply; 32+ messages in thread
From: Pierre Weis @ 2002-10-04  9:07 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: luc.maranget, caml-list

[...]
> I meant what I wrote. The %s conversion stops reading at the 
> first whitespace character. However, ocaml does not like 
> the  "%[^]" which, in my opinion, is to be considered a 
> mini-bug. "%[^]" should be interpreted as "the set of all 
> characters except none", which is "the set of all 
> characters", which can also be expressed, more verbosely, as 
> "%[\000-\255]". By the same standards, "%[]" is rejected, 
> when it should be interpreted as "the set containing no 
> characters", or more verbosely "%[^\000-\255]"
[...]
> Alex

This is not a mini-bug, this is a carefully crafted feature and
thoroughly considered design decision :(

"%[]" is not allowed because we need to allow the matching of the
closing bracket. Hence, if ']' just follows the opening bracket (or
the ^ character, in case of negative range) it is considered as a
plain ']' (or ascii code 93) to be matched.

So "%[]]" means matching ']' (well, more precisely zero or more ']');
more generally, "%[]range]" means matching ']' or range; "%[^]range]"
means matching any character different from ']' and not belonging to
range.

Admitedly, we could have made a different decision, such as a special
escape for ']' in a range that would have made possible your
interpretation of "%[]". However, I considered that the matching of an
empty range of characters (or conversely a full range of characters)
was way less useful and frequent than matching a ']'. Hence, the more
complex expressions "%[^\000-\255]" and "%[\000-\255]" for the seldom
used ranges.

To end with, I want also to elaborate a bit on the last sentence of
the Scanf documentation because many people misunderstand it:

   Note: the [scanf] facility is not intended for heavy duty
   lexical analysis and parsing.

As you said ``I meant what I wrote''. I did not mean that [scanf] is
slow (it is not). I did not mean that it is not powerful (since it is
much more powerful than the corresponding C facility). I meant that it
is perfectly ok to write complex input reading functions (up to, say,
a polymorphic list scanner for instance), but [scanf] is not the right
tool to write a full-fledge Caml parser.

On the other hand, writing a polymorphic list scanner using lex and
yacc seems to me way more difficult than the 10 or 15 lines of code
you need to implement the polymorphic list scanner, if you use the
[Scanf] module facilities :)

May be this note should be removed, since, at last, it just means ``Use
the right tool for the work at hand'', which evidently goes without
saying when you are talking to people that already chose Objective
Caml to write their programs !

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-04  9:07     ` Pierre Weis
@ 2002-10-04  9:31       ` Alessandro Baretta
  2002-10-04 10:03         ` Pierre Weis
  0 siblings, 1 reply; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-04  9:31 UTC (permalink / raw)
  To: Pierre Weis, Ocaml



Pierre Weis wrote:
> This is not a mini-bug, this is a carefully crafted feature and
> thoroughly considered design decision :(
> 
> "%[]" is not allowed because we need to allow the matching of the
> closing bracket. Hence, if ']' just follows the opening bracket (or
> the ^ character, in case of negative range) it is considered as a
> plain ']' (or ascii code 93) to be matched.
> 
> So "%[]]" means matching ']' (well, more precisely zero or more ']');
> more generally, "%[]range]" means matching ']' or range; "%[^]range]"
> means matching any character different from ']' and not belonging to
> range.

I probably did not consider the problem thoroughly enough. I 
was expecting "%[]]" to match a range of ']' and "%[]" to 
match the empty range of characters (which is a rather 
useless construct anyway, as you point out). Now I realize 
this would render almost impossible the interpretation of a 
such a format as "%[]abcdefg...": you simply never know if 
it is the prefix of a range conversion specifier or a empty 
range conversion specifier followed by a string constant 
specifier.

While the empty range conversion is admittedly useless, a 
full range conversion is a whole different story. Coding it 
as "%[\000-\255]" is possible, but maybe it would useful to 
add a "%z" specifier to mean "read till the end of input".

What do you think?

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-04  9:31       ` Alessandro Baretta
@ 2002-10-04 10:03         ` Pierre Weis
  2002-10-04 10:23           ` Alessandro Baretta
  0 siblings, 1 reply; 32+ messages in thread
From: Pierre Weis @ 2002-10-04 10:03 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: pierre.weis, caml-list

[...]
> I probably did not consider the problem thoroughly enough. I 
> was expecting "%[]]" to match a range of ']' and "%[]" to 
> match the empty range of characters (which is a rather 
> useless construct anyway, as you point out). Now I realize 
> this would render almost impossible the interpretation of a 
> such a format as "%[]abcdefg...": you simply never know if 
> it is the prefix of a range conversion specifier or a empty 
> range conversion specifier followed by a string constant 
> specifier.
> 
> While the empty range conversion is admittedly useless, a 
> full range conversion is a whole different story. Coding it 
> as "%[\000-\255]" is possible, but maybe it would useful to 
> add a "%z" specifier to mean "read till the end of input".
> 
> What do you think?
> 
> Alex

I should say that I am reluctant to had a special typing rule for the
new specifier you proposed, when "%[\000-\255]" does perfectly the job
and does not require any addition to the type-checker nor to the
implementation of Scanf.

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-04 10:03         ` Pierre Weis
@ 2002-10-04 10:23           ` Alessandro Baretta
  2002-10-04 12:11             ` Remi VANICAT
  0 siblings, 1 reply; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-04 10:23 UTC (permalink / raw)
  To: Pierre Weis, ocaml



Pierre Weis wrote:
> [...]

> I should say that I am reluctant to had a special typing rule for the
> new specifier you proposed, when "%[\000-\255]" does perfectly the job
> and does not require any addition to the type-checker nor to the
> implementation of Scanf.
> 
> Pierre Weis

Why do you mention the type checker? Is each conversion 
specifier a special case for the type checker?

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-03  8:31 ` [Caml-list] Pattern matching and strings Sven Luther
@ 2002-10-04 12:00   ` Andreas Rossberg
  2002-10-04 14:21     ` Kontra, Gergely
                       ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Andreas Rossberg @ 2002-10-04 12:00 UTC (permalink / raw)
  To: Ocaml

Sven Luther wrote:
> 
> On Wed, Oct 02, 2002 at 04:12:34PM +0200, Alessandro Baretta wrote:
> > I have to do a little bit of pattern matching on strings. My
> > first instict was to write something like the following.
> >
> > let foo x = ...
> > let bar x = ...
> > ... = function
> > | "foo" ^ rest -> foo rest
> > | "bar" ^ rest -> bar rest
> > | _ -> raise Unrecognized
> 
> What about :
> 
> ... = function
>   | str when String.sub str 0 3 = "foo" -> foo (String.sub str 2 (String.length str - 3))
>   | str when String.sub str 0 3 = "bar" -> bar (String.sub str 2 (String.length str - 3))
>   | _ -> raise Unrecognized
> 
> Sure, this code is not very optimal, i guess you could write a nicer
> function which will test the string incrementally using just String.get
> or something such, but i suppose it will do the thing you want.

The SML basis library provides the nice but often overlooked concept of
substrings (or more generally, vector slices,
http://SML.sourceforge.net/Basis/substring.html). Ported to Caml the
Substring module would enable

> ... = function
>   | s when Substring.is_prefix "foo" s -> foo (Substring.triml 3 s)
>   | s when Substring.is_prefix "bar" s -> bar (Substring.triml 3 s)
>   | _ -> raise Unrecognized

where your parsing functions operate on substrings instead of strings.
Such an approach seems like a good compromise between use of a heavy
regexp lib and inefficient repeated copying of parts of strings.

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
 as kids, we would all be running around in darkened rooms, munching
 magic pills, and listening to repetitive electronic music."
 - Kristian Wilson, Nintendo Inc.
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-04 10:23           ` Alessandro Baretta
@ 2002-10-04 12:11             ` Remi VANICAT
  2002-10-04 12:40               ` [Caml-list] Ocaml 3.06 Win2K OCAML/C link problem Ward Wheeler
                                 ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Remi VANICAT @ 2002-10-04 12:11 UTC (permalink / raw)
  To: caml-list

Alessandro Baretta <alex@baretta.com> writes:

> Pierre Weis wrote:
>> [...]
>
>> I should say that I am reluctant to had a special typing rule for the
>> new specifier you proposed, when "%[\000-\255]" does perfectly the job
>> and does not require any addition to the type-checker nor to the
>> implementation of Scanf.
>> Pierre Weis
>
> Why do you mention the type checker? Is each conversion specifier a
> special case for the type checker?

Of course it is :

# Scanf.scanf "%s %d %i";;
- : (string -> int -> int -> '_a) -> '_a = <fun>

to type this, the type checker have to look inside the format and find
that %s look for a string, %d and %i an int.

-- 
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] 32+ messages in thread

* [Caml-list] Ocaml 3.06 Win2K OCAML/C link problem
  2002-10-04 12:11             ` Remi VANICAT
@ 2002-10-04 12:40               ` Ward Wheeler
  2002-10-04 13:12               ` [Caml-list] Pattern matching and strings (and a mini-bug inScanf) Frederic van der Plancke
  2002-10-04 19:31               ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
  2 siblings, 0 replies; 32+ messages in thread
From: Ward Wheeler @ 2002-10-04 12:40 UTC (permalink / raw)
  To: caml-list; +Cc: Xavier Leroy

Just updated to 3.06.  Unix make etc are fine, but in linling (compiling is 
fine) for Win2K (using MSVC and MASM) I get the following error:

	LINK : fatal error LNK1181: cannot open input file "C:\Program.obj"
	Error during linking

This did not happen with OCMAL 3.04 using the same versions of MSVC and 
MSAM.  Any ideas anybody?

Ward Wheeler

*********************************
Ward Wheeler
Division of Invertebrate Zoology
American Museum of Natural History
Central Park West @ 79th St.
New York, NY 10024-5192
1-212-769-5754 (Voice)
1-212-769-5277 (FAX)
*********************************

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-02 17:15     ` Luc Maranget
  2002-10-02 18:30       ` Alessandro Baretta
@ 2002-10-04 13:01       ` Florian Douetteau
  1 sibling, 0 replies; 32+ messages in thread
From: Florian Douetteau @ 2002-10-04 13:01 UTC (permalink / raw)
  To: Ocaml

On Wed, 2 Oct 2002, Luc Maranget wrote:

> > I realize this, but I also believe that pattern matching on
> > strings is something that would make string-processing code
> > much clearer and more concise. I don't mean that we have to
>
> Ok, but again, I object to adding just one special case,
> some uniform treatement is required here, and it looks difficult.
>

Regular expression types cannot be used with Ocaml's strings
since they are mutable; so that any Ocaml extension supporting regexp
types will have to,  either (or both):
  1) provide it's own immutable string type
  2) use trivial typechecking for regexp patterns on immutable strings

IMHO, regexp patterns on mutable strings could thus be supported
without fear of blocking any future extensions.

Anyway this is only a syntactic problem, already discussed on the
list (see http://caml.inria.fr/archives/200107/msg00187.html)

--
Florian

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug inScanf)
  2002-10-04 12:11             ` Remi VANICAT
  2002-10-04 12:40               ` [Caml-list] Ocaml 3.06 Win2K OCAML/C link problem Ward Wheeler
@ 2002-10-04 13:12               ` Frederic van der Plancke
  2002-10-04 19:31               ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
  2 siblings, 0 replies; 32+ messages in thread
From: Frederic van der Plancke @ 2002-10-04 13:12 UTC (permalink / raw)
  To: owner-caml-list; +Cc: caml-list



Remi VANICAT wrote:
> 
> Alessandro Baretta <alex@baretta.com> writes:
> 
> > Pierre Weis wrote:
> >> [...]
> >
> >> I should say that I am reluctant to had a special typing rule for the
> >> new specifier you proposed, when "%[\000-\255]" does perfectly the job
> >> and does not require any addition to the type-checker nor to the
> >> implementation of Scanf.
> >> Pierre Weis
> >
> > Why do you mention the type checker? Is each conversion specifier a
> > special case for the type checker?
> 
> Of course it is :
> 
> # Scanf.scanf "%s %d %i";;
> - : (string -> int -> int -> '_a) -> '_a = <fun>
> 
> to type this, the type checker have to look inside the format and find
> that %s look for a string, %d and %i an int.

But if %z returns a string like %s, does it need an additional case in OCaml's
global *type*checker* ? Shouldn't it suffice to modify the function in the scanf
implementation that determines the type of a format ?

Frédéric vdP

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-04 12:00   ` Andreas Rossberg
@ 2002-10-04 14:21     ` Kontra, Gergely
  2002-10-04 15:14     ` Luc Maranget
  2002-10-04 19:13     ` [Caml-list] Pattern matching and strings Sven LUTHER
  2 siblings, 0 replies; 32+ messages in thread
From: Kontra, Gergely @ 2002-10-04 14:21 UTC (permalink / raw)
  To: Ocaml

[..]
>The SML basis library provides the nice but often overlooked concept of
>substrings (or more generally, vector slices,

It seems, that core ocaml doesn't have any kind of good string
processing :(. Ok, it has some, but you need to type very much...
+-[Kontra, Gergely @ Budapest University of Technology and Economics]-+
|         Email: kgergely@mcl.hu,  kgergely@turul.eet.bme.hu          |
|  URL:   turul.eet.bme.hu/~kgergely    Mobile: (+36 20) 356 9656     |
+-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
.
Magyar php mirror es magyar php dokumentacio: http://hu.php.net

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-04 12:00   ` Andreas Rossberg
  2002-10-04 14:21     ` Kontra, Gergely
@ 2002-10-04 15:14     ` Luc Maranget
  2002-10-04 19:38       ` Alessandro Baretta
  2002-10-04 19:13     ` [Caml-list] Pattern matching and strings Sven LUTHER
  2 siblings, 1 reply; 32+ messages in thread
From: Luc Maranget @ 2002-10-04 15:14 UTC (permalink / raw)
  To: Andreas Rossberg; +Cc: Ocaml

> I have to do a little bit of pattern matching on strings. My
 > first instict was to write something like the following.
 >
 > let foo x = ...
 > let bar x = ...
 > ... = function
 > | "foo" ^ rest -> foo rest
 > | "bar" ^ rest -> bar rest
 > | _ -> raise Unrecognized


I have thought about that a little.

My first guess is that such matching should be distinct from
ordinary PM, mixing the two would be an implementor nightmare.

My second guess is that what you want is regexp matching + a construct
for binding subparts of the matched string (maybe I am wrong here).

Using ocamllex syntax for patterns (+ as) your exemple could be written

regexpmatch s with
| "foo" (_* as x)  -> foo x
| "bar" (_* as x)  -> bar x
| _*               -> raise Unrecognized


This would be much nicer than using various regexp packages API, the
real add-on being the variables in place of \1, \2 etc.

Of course this would work only in the case where all patterns are known
statically and implementation is not 100% trivial, if you want some
warnings and compile-time production of matching automata.
(ie if you do not rely on regexp package).

In fact such, an extension is probably feasible using camlp4 and this
would probably be the best solution, to avoid extra-complexity in the
compiler itself.


In the end, do not hold your breath. I won't probably do that.
But it can be a interesting project for a compiler course...

--Luc



-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-04 12:00   ` Andreas Rossberg
  2002-10-04 14:21     ` Kontra, Gergely
  2002-10-04 15:14     ` Luc Maranget
@ 2002-10-04 19:13     ` Sven LUTHER
  2 siblings, 0 replies; 32+ messages in thread
From: Sven LUTHER @ 2002-10-04 19:13 UTC (permalink / raw)
  To: Andreas Rossberg; +Cc: Ocaml

On Fri, Oct 04, 2002 at 02:00:37PM +0200, Andreas Rossberg wrote:
> Sven Luther wrote:
> > 
> > On Wed, Oct 02, 2002 at 04:12:34PM +0200, Alessandro Baretta wrote:
> > > I have to do a little bit of pattern matching on strings. My
> > > first instict was to write something like the following.
> > >
> > > let foo x = ...
> > > let bar x = ...
> > > ... = function
> > > | "foo" ^ rest -> foo rest
> > > | "bar" ^ rest -> bar rest
> > > | _ -> raise Unrecognized
> > 
> > What about :
> > 
> > ... = function
> >   | str when String.sub str 0 3 = "foo" -> foo (String.sub str 2 (String.length str - 3))
> >   | str when String.sub str 0 3 = "bar" -> bar (String.sub str 2 (String.length str - 3))
> >   | _ -> raise Unrecognized
> > 
> > Sure, this code is not very optimal, i guess you could write a nicer
> > function which will test the string incrementally using just String.get
> > or something such, but i suppose it will do the thing you want.
> 
> The SML basis library provides the nice but often overlooked concept of
> substrings (or more generally, vector slices,
> http://SML.sourceforge.net/Basis/substring.html). Ported to Caml the
> Substring module would enable
> 
> > ... = function
> >   | s when Substring.is_prefix "foo" s -> foo (Substring.triml 3 s)
> >   | s when Substring.is_prefix "bar" s -> bar (Substring.triml 3 s)
> >   | _ -> raise Unrecognized
> 
> where your parsing functions operate on substrings instead of strings.
> Such an approach seems like a good compromise between use of a heavy
> regexp lib and inefficient repeated copying of parts of strings.

Well, like i said, it was just a quick implementation, but i am sure you
can do this more or less optimaly with a hand coded String.get using
comparison function. I don't know if you really can escape the use of
the final copying of the string though.

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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-04 12:11             ` Remi VANICAT
  2002-10-04 12:40               ` [Caml-list] Ocaml 3.06 Win2K OCAML/C link problem Ward Wheeler
  2002-10-04 13:12               ` [Caml-list] Pattern matching and strings (and a mini-bug inScanf) Frederic van der Plancke
@ 2002-10-04 19:31               ` Alessandro Baretta
  2002-10-07  7:17                 ` Pierre Weis
  2 siblings, 1 reply; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-04 19:31 UTC (permalink / raw)
  To: Ocaml



Remi VANICAT wrote:
> Alessandro Baretta <alex@baretta.com> writes:
> 
> 
>>Pierre Weis wrote:
>>
>>>[...]
>>
>>>I should say that I am reluctant to had a special typing rule for the
>>>new specifier you proposed, when "%[\000-\255]" does perfectly the job
>>>and does not require any addition to the type-checker nor to the
>>>implementation of Scanf.
>>>Pierre Weis
>>
>>Why do you mention the type checker? Is each conversion specifier a
>>special case for the type checker?
> 
> 
> Of course it is :
> 
> # Scanf.scanf "%s %d %i";;
> - : (string -> int -> int -> '_a) -> '_a = <fun>
> 
> to type this, the type checker have to look inside the format and find
> that %s look for a string, %d and %i an int.
> 

I did not make myself clear. Of course, the type checker has
to delve into a format string to figure out how to type
Scanf.sscanf "%s %d %i", but that does not mean that "%s
%[abc] %[^def]" requires three different "special cases" in
the type checker. I haven't read how the typechecker reads
format strings, but I would expect that it should only be
intersted in the *type* of the conversion specifier, as
opposed to how the conversion is implemented. All
conversions specifying integers should be treated uniformly
by the type checker; by the same standards all conversions
specifying strings should be treated in the same way. A "%z"
specifier meaning "everything till the end of input" should
look no different to the type checker than a "%s" or a "%[abc]".

Anyhow, I can live with "%[\000-\255]", but I still think
that a "%z" would be a worthy addition.

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings
  2002-10-04 15:14     ` Luc Maranget
@ 2002-10-04 19:38       ` Alessandro Baretta
  2002-10-05  6:34         ` [Caml-list] Camlp4 (Was: Pattern matching and strings) Daniel de Rauglaudre
  0 siblings, 1 reply; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-04 19:38 UTC (permalink / raw)
  To: Luc Maranget, Ocaml



Luc Maranget wrote:

> I have thought about that a little.
> 
> My first guess is that such matching should be distinct from
> ordinary PM, mixing the two would be an implementor nightmare.
> 
> My second guess is that what you want is regexp matching + a construct
> for binding subparts of the matched string (maybe I am wrong here).
> 
> Using ocamllex syntax for patterns (+ as) your exemple could be written
> 
> regexpmatch s with
> | "foo" (_* as x)  -> foo x
> | "bar" (_* as x)  -> bar x
> | _*               -> raise Unrecognized

This is basically what I was looking for.

> This would be much nicer than using various regexp packages API, the
> real add-on being the variables in place of \1, \2 etc.

Precisely.

> ...
> 
> In fact such, an extension is probably feasible using camlp4 and this
> would probably be the best solution, to avoid extra-complexity in the
> compiler itself.

I really must get around to learning Camlp4. Why did no one 
teach it to me when I was at the X?

> In the end, do not hold your breath. I won't probably do that.
> But it can be a interesting project for a compiler course...
> 
> --Luc

;)

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-04 19:38       ` Alessandro Baretta
@ 2002-10-05  6:34         ` Daniel de Rauglaudre
  2002-10-05 12:47           ` Sven LUTHER
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-05  6:34 UTC (permalink / raw)
  To: caml-list

Hi,

On Fri, Oct 04, 2002 at 09:38:09PM +0200, Alessandro Baretta wrote:

> I really must get around to learning Camlp4. Why did no one 
> teach it to me when I was at the X?

Camlp4 is not really part of OCaml: it is just an OCaml program.

It has been included in OCaml in version 3.04, but I have considered
since several months that it is an error, especially as the OCaml
compiler does not use it, and as some people of the OCaml team have
still considered that it is "waste of time".

It is actually now developped separatedely (there is a separated CVS
version), and I am fighting in order that it is distributed separately
in next version 3.07.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-05 12:47           ` Sven LUTHER
@ 2002-10-05 12:42             ` Daniel de Rauglaudre
  2002-10-05 13:41               ` Michel Mauny
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-05 12:42 UTC (permalink / raw)
  To: caml-list

Hi,

On Sat, Oct 05, 2002 at 02:47:34PM +0200, Sven LUTHER wrote:

> Will the streams be again part of ocaml then, or not ?

This can be discussed with the OCaml team.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-05  6:34         ` [Caml-list] Camlp4 (Was: Pattern matching and strings) Daniel de Rauglaudre
@ 2002-10-05 12:47           ` Sven LUTHER
  2002-10-05 12:42             ` Daniel de Rauglaudre
  0 siblings, 1 reply; 32+ messages in thread
From: Sven LUTHER @ 2002-10-05 12:47 UTC (permalink / raw)
  To: Daniel de Rauglaudre; +Cc: caml-list

On Sat, Oct 05, 2002 at 08:34:51AM +0200, Daniel de Rauglaudre wrote:
> Hi,
> 
> On Fri, Oct 04, 2002 at 09:38:09PM +0200, Alessandro Baretta wrote:
> 
> > I really must get around to learning Camlp4. Why did no one 
> > teach it to me when I was at the X?
> 
> Camlp4 is not really part of OCaml: it is just an OCaml program.
> 
> It has been included in OCaml in version 3.04, but I have considered
> since several months that it is an error, especially as the OCaml
> compiler does not use it, and as some people of the OCaml team have
> still considered that it is "waste of time".
> 
> It is actually now developped separatedely (there is a separated CVS
> version), and I am fighting in order that it is distributed separately
> in next version 3.07.

:((((

Will the streams be again part of ocaml then, or not ?

Friendly,

Sven Luther
l> 
> -- 
> Daniel de RAUGLAUDRE
> daniel.de_rauglaudre@inria.fr
> http://cristal.inria.fr/~ddr/
> -------------------
> 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
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-05 12:42             ` Daniel de Rauglaudre
@ 2002-10-05 13:41               ` Michel Mauny
  2002-10-05 13:47                 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 32+ messages in thread
From: Michel Mauny @ 2002-10-05 13:41 UTC (permalink / raw)
  To: caml-list

Alessandro Baretta wrote/écrivait (Oct 04 2002, 09:38PM +0200):
> I really must get around to learning Camlp4. Why did no one 
> teach it to me when I was at the X?

Any X teacher around? :-)

Daniel gave his personal point of view about what should be the status
of Camlp4, whereas the question was why teachers at École
Polytechnique didn't include Camlp4 in their OCaml courses. Slightly
different matters.

As a consequence, let me repeat that Camlp4 is still part of the OCaml
distribution, as all of you noticed. Even though the process of
updating Camlp4 in the CVS OCaml tree is more painful than before, the
camlp4 and the ocaml/camlp4 trees get merged at least at each
distribution.

So, there is no reason so far to worry about the status of OCaml
streams.

Daniel de Rauglaudre wrote/écrivait (Oct 05 2002, 02:42PM +0200):
> On Sat, Oct 05, 2002 at 02:47:34PM +0200, Sven LUTHER wrote:
> > Will the streams be again part of ocaml then, or not ?
> This can be discussed with the OCaml team.

Done.

-- 
Michel Mauny
Michel.Mauny@inria.fr
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-05 13:41               ` Michel Mauny
@ 2002-10-05 13:47                 ` Daniel de Rauglaudre
  2002-10-05 14:09                   ` Michel Mauny
  0 siblings, 1 reply; 32+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-05 13:47 UTC (permalink / raw)
  To: caml-list

Hi,

On Sat, Oct 05, 2002 at 03:41:33PM +0200, Michel Mauny wrote:

> As a consequence, let me repeat that Camlp4 is still part of the OCaml
> distribution, as all of you noticed.

Michel Mauny gave here his personnal point of view, but told me, some
time ago, that "liberty of expression" is good for research. I then use
it, as it is my right, to contest the political decision of keeping
Camlp4 in OCaml, which can only come to the end of Camlp4.

If I say: "Camlp4 must be separated", it is just to say, to tell
everybody of you, that I want to continue to work on it, to improve
it, to receive your remarks and to debug it.

Therefore, I continue fighting for the separation. Except, of course,
if insults against my work are no more considered as "liberty of expression"
and if I can be sure that these insults stop.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-05 13:47                 ` Daniel de Rauglaudre
@ 2002-10-05 14:09                   ` Michel Mauny
  2002-10-05 18:13                     ` Alessandro Baretta
  0 siblings, 1 reply; 32+ messages in thread
From: Michel Mauny @ 2002-10-05 14:09 UTC (permalink / raw)
  To: Daniel de Rauglaudre; +Cc: caml-list

Daniel de Rauglaudre wrote/écrivait (Oct 05 2002, 03:47PM +0200):
> On Sat, Oct 05, 2002 at 03:41:33PM +0200, Michel Mauny wrote:
> 
> > As a consequence, let me repeat that Camlp4 is still part of the OCaml
> > distribution, as all of you noticed.
> 
> Michel Mauny gave here his personnal point of view, 

Well, the sentence you quote looks more like a fact, to me.

-- 
Michel Mauny
Michel.Mauny@inria.fr
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Camlp4 (Was: Pattern matching and strings)
  2002-10-05 14:09                   ` Michel Mauny
@ 2002-10-05 18:13                     ` Alessandro Baretta
  2002-10-05 20:30                       ` [Caml-list] Future of Camlp4 Daniel de Rauglaudre
  0 siblings, 1 reply; 32+ messages in thread
From: Alessandro Baretta @ 2002-10-05 18:13 UTC (permalink / raw)
  To: Michel.Mauny, Daniel de Rauglaudre, Ocaml



Michel Mauny wrote:
> Daniel de Rauglaudre wrote/écrivait (Oct 05 2002, 03:47PM +0200):
> 
>>On Sat, Oct 05, 2002 at 03:41:33PM +0200, Michel Mauny wrote:
>>
>>
>>>As a consequence, let me repeat that Camlp4 is still part of the OCaml
>>>distribution, as all of you noticed.
>>
>>Michel Mauny gave here his personnal point of view, 
> 
> 
> Well, the sentence you quote looks more like a fact, to me.
> 

I am terribly sorry to have restarted this latent flame-war 
on the status of CamlP4. I hope the best for the evolution 
of the language--including such powerful extensions as a 
CamlP4, and shame to me for not having learned it yet.

Alex

-------------------
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] 32+ messages in thread

* Re: [Caml-list] Future of Camlp4
  2002-10-05 18:13                     ` Alessandro Baretta
@ 2002-10-05 20:30                       ` Daniel de Rauglaudre
  0 siblings, 0 replies; 32+ messages in thread
From: Daniel de Rauglaudre @ 2002-10-05 20:30 UTC (permalink / raw)
  To: caml-list

Hi,

On Sat, Oct 05, 2002 at 08:13:55PM +0200, Alessandro Baretta wrote:

> I am terribly sorry to have restarted this latent flame-war 
> on the status of CamlP4. I hope the best for the evolution 
> of the language--including such powerful extensions as a 
> CamlP4, and shame to me for not having learned it yet.

Don't worry: Michel was right by telling that it is just a pretext for
me to speak again about this problem. After all that time, I just saw
that he did nothing to resolve this problem, and I just take that
occasion to speak about it.

Bury a conflict is never a solution.

We all want that OCaml and Camlp4 succeed. In this case, things must
be clear between us, and they are not.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
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] 32+ messages in thread

* Re: [Caml-list] Pattern matching and strings (and a mini-bug in Scanf)
  2002-10-04 19:31               ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
@ 2002-10-07  7:17                 ` Pierre Weis
  0 siblings, 0 replies; 32+ messages in thread
From: Pierre Weis @ 2002-10-07  7:17 UTC (permalink / raw)
  To: Alessandro Baretta; +Cc: caml-list

[...]
> I did not make myself clear. Of course, the type checker has
> to delve into a format string to figure out how to type
> Scanf.sscanf "%s %d %i", but that does not mean that "%s
> %[abc] %[^def]" requires three different "special cases" in
> the type checker.

You're right it only needs two special cases: %s and %[...]

> I haven't read how the typechecker reads
> format strings, but I would expect that it should only be
> intersted in the *type* of the conversion specifier, as
> opposed to how the conversion is implemented. All
> conversions specifying integers should be treated uniformly
> by the type checker; by the same standards all conversions
> specifying strings should be treated in the same way.

Absolutely.

> A "%z" specifier meaning "everything till the end of input" should
> look no different to the type checker than a "%s" or a "%[abc]".

Evidently, but the type-checker needs a special case to match %z
anyhow. Also remember that the type-checker is typing format, hence
those typing are used both for printing and scaning. It means we have
to be careful to have both interpretations to each convertion. So what
would be the meaning of Printf.printf "%z" ?

> Anyhow, I can live with "%[\000-\255]", but I still think
> that a "%z" would be a worthy addition.
> 
> Alex

Thank you for living with "%[\000-\255]".

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


-------------------
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] 32+ messages in thread

end of thread, other threads:[~2002-10-07  7:17 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-02 14:12 [Caml-list] Pattern matching and strings Alessandro Baretta
2002-10-02 15:02 ` Luc Maranget
2002-10-02 16:21   ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
2002-10-02 17:15     ` Luc Maranget
2002-10-02 18:30       ` Alessandro Baretta
2002-10-02 18:32         ` Benjamin C. Pierce
2002-10-04 13:01       ` Florian Douetteau
2002-10-04  9:07     ` Pierre Weis
2002-10-04  9:31       ` Alessandro Baretta
2002-10-04 10:03         ` Pierre Weis
2002-10-04 10:23           ` Alessandro Baretta
2002-10-04 12:11             ` Remi VANICAT
2002-10-04 12:40               ` [Caml-list] Ocaml 3.06 Win2K OCAML/C link problem Ward Wheeler
2002-10-04 13:12               ` [Caml-list] Pattern matching and strings (and a mini-bug inScanf) Frederic van der Plancke
2002-10-04 19:31               ` [Caml-list] Pattern matching and strings (and a mini-bug in Scanf) Alessandro Baretta
2002-10-07  7:17                 ` Pierre Weis
2002-10-02 20:59 ` [Caml-list] views for strings (was: Pattern matching and strings) Chris Hecker
2002-10-02 23:09   ` [Caml-list] " Alessandro Baretta
2002-10-03  8:31 ` [Caml-list] Pattern matching and strings Sven Luther
2002-10-04 12:00   ` Andreas Rossberg
2002-10-04 14:21     ` Kontra, Gergely
2002-10-04 15:14     ` Luc Maranget
2002-10-04 19:38       ` Alessandro Baretta
2002-10-05  6:34         ` [Caml-list] Camlp4 (Was: Pattern matching and strings) Daniel de Rauglaudre
2002-10-05 12:47           ` Sven LUTHER
2002-10-05 12:42             ` Daniel de Rauglaudre
2002-10-05 13:41               ` Michel Mauny
2002-10-05 13:47                 ` Daniel de Rauglaudre
2002-10-05 14:09                   ` Michel Mauny
2002-10-05 18:13                     ` Alessandro Baretta
2002-10-05 20:30                       ` [Caml-list] Future of Camlp4 Daniel de Rauglaudre
2002-10-04 19:13     ` [Caml-list] Pattern matching and strings Sven LUTHER

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