Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Jym <jymoyen@ens-lyon.fr>, caml-list@inria.fr
Subject: Re: probleme de parsing ?
Date: Mon, 6 Mar 2000 09:52:31 +0100	[thread overview]
Message-ID: <20000306095231.29343@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.GSO.4.21.0002292003300.28398-100000@jamaique>; from Jean-Yves Moyen on Tue, Feb 29, 2000 at 08:06:51PM +0100

> Bonjour, il y a apparamment un probleme de parsing des chaines dans la
> fonction int_of_string : les espaces precedents (ou suivant) les nombres
> ne sont pas eliminer. En revanche, il le sont dans la fonction
> float_of_string :
> Est-ce voulu ? Si oui, pourquoi avoir introduit cette difference ?

Ce n'est pas vraiment voulu.  La fonction int_of_string est
implémentée dans le runtime Caml, et effectue un parsing précis de la
chaîne argument.  En revanche, float_of_string est un appel à la
fonction atof() de la bibliothèque C standard, laquelle effectue un
parsing un peu plus lâche de la chaîne, avec espaces optionnels au
début.  Aussi, atof() n'échoue jamais, mais renvoie 0.0 pour une
chaîne mal formée.

Il ne serait pas difficile de "durcir" float_of_string par une passe
de vérification supplémentaire; mais est-ce bien la peine?

- Xavier Leroy



      parent reply	other threads:[~2000-03-06 13:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-29 19:06 Jean-Yves Moyen
2000-03-01 17:19 ` Sven LUTHER
2000-03-06  9:07   ` Xavier Leroy
2000-03-06  9:43     ` Sven LUTHER
2000-03-01 18:07 ` Vitaly Lugovsky
2000-03-02  2:26 ` Max Skaller
2000-03-06  8:52 ` Xavier Leroy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000306095231.29343@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jymoyen@ens-lyon.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox