* [Caml-list] unused variables warning
@ 2001-04-28 9:57 Pixel
2001-04-29 8:15 ` Vitaly Lugovsky
2002-09-09 21:24 ` [Caml-list] " Pixel
0 siblings, 2 replies; 7+ messages in thread
From: Pixel @ 2001-04-28 9:57 UTC (permalink / raw)
To: caml-list
Is there any way to ask ocamlc for an "unused variable" warning?
let f x =
let x' = <...> in
x
would issue something like
File "test.ml", line 2, characters 3-18:
Unused variable x'
thanks, cu Pixel.
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] unused variables warning
2001-04-28 9:57 [Caml-list] unused variables warning Pixel
@ 2001-04-29 8:15 ` Vitaly Lugovsky
2001-04-29 9:58 ` Pixel
2001-04-29 10:14 ` Marcin 'Qrczak' Kowalczyk
2002-09-09 21:24 ` [Caml-list] " Pixel
1 sibling, 2 replies; 7+ messages in thread
From: Vitaly Lugovsky @ 2001-04-29 8:15 UTC (permalink / raw)
To: Pixel; +Cc: caml-list
On Sat, 28 Apr 2001, Pixel wrote:
> Is there any way to ask ocamlc for an "unused variable" warning?
>
> let f x =
> let x' = <...> in
> x
>
> would issue something like
>
> File "test.ml", line 2, characters 3-18:
> Unused variable x'
It's "unused" and can be optimized out only when <...> is a pure
functional statement (not changing global state). There is no clean way to
figure this out, since we can use foreign functions, and "purity" is not
specified in a module signature. 'tis a very interesting suggestion:
specify pure functional and state-changing functions in signatures
(automaticaly or manualy), and use this info for a better optimizations.
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] unused variables warning
2001-04-29 8:15 ` Vitaly Lugovsky
@ 2001-04-29 9:58 ` Pixel
2001-04-29 13:06 ` Sven LUTHER
2001-04-29 10:14 ` Marcin 'Qrczak' Kowalczyk
1 sibling, 1 reply; 7+ messages in thread
From: Pixel @ 2001-04-29 9:58 UTC (permalink / raw)
To: Vitaly Lugovsky; +Cc: caml-list
Vitaly Lugovsky <vsl@ontil.ihep.su> writes:
[...]
> > let f x =
> > let x' = <...> in
> > x
> >
> > would issue something like
> >
> > File "test.ml", line 2, characters 3-18:
> > Unused variable x'
>
> It's "unused" and can be optimized out only when <...> is a pure
> functional statement (not changing global state).
even if the <...> is unpure, caml could warn that x' is unused. It doesn't mean
in any way that computing x' is unnecessary.
and caml should not warn for
let _x' = <...> in
> There is no clean way to
> figure this out, since we can use foreign functions, and "purity" is not
> specified in a module signature. 'tis a very interesting suggestion:
> specify pure functional and state-changing functions in signatures
> (automaticaly or manualy), and use this info for a better optimizations.
that would be cool, but it's much more complicated than my simple suggestion :)
cu Pixel.
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] unused variables warning
2001-04-29 9:58 ` Pixel
@ 2001-04-29 13:06 ` Sven LUTHER
2001-04-29 13:14 ` Pixel
0 siblings, 1 reply; 7+ messages in thread
From: Sven LUTHER @ 2001-04-29 13:06 UTC (permalink / raw)
To: Pixel; +Cc: Vitaly Lugovsky, caml-list
On Sun, Apr 29, 2001 at 11:58:22AM +0200, Pixel wrote:
> Vitaly Lugovsky <vsl@ontil.ihep.su> writes:
>
> [...]
>
> > > let f x =
> > > let x' = <...> in
> > > x
> > >
> > > would issue something like
> > >
> > > File "test.ml", line 2, characters 3-18:
> > > Unused variable x'
> >
> > It's "unused" and can be optimized out only when <...> is a pure
> > functional statement (not changing global state).
>
> even if the <...> is unpure, caml could warn that x' is unused. It doesn't mean
> in any way that computing x' is unnecessary.
>
> and caml should not warn for
>
> let _x' = <...> in
I guess you mean just :
let _ = <...> in
?
Friendly,
Sven Luther
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] unused variables warning
2001-04-29 13:06 ` Sven LUTHER
@ 2001-04-29 13:14 ` Pixel
0 siblings, 0 replies; 7+ messages in thread
From: Pixel @ 2001-04-29 13:14 UTC (permalink / raw)
To: Sven LUTHER; +Cc: Vitaly Lugovsky, caml-list
Sven LUTHER <luther@dpt-info.u-strasbg.fr> writes:
> > even if the <...> is unpure, caml could warn that x' is unused. It doesn't mean
> > in any way that computing x' is unnecessary.
> >
> > and caml should not warn for
> >
> > let _x' = <...> in
>
> I guess you mean just :
>
> let _ = <...> in
well, no. In fact i thought "_x" and "_" were the same, discarded,
non-accessible variables. I'm wrong on this.
the manual recommend not to use _xxx variables, otherwise it could have been a
way to write things like:
let _no_warning_but_meaningful_name = <...> in
but it would be another rule to learn: ``no warning for unused variables
starting with _'' (which is just what Haskell is doing).
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Caml-list] unused variables warning
2001-04-29 8:15 ` Vitaly Lugovsky
2001-04-29 9:58 ` Pixel
@ 2001-04-29 10:14 ` Marcin 'Qrczak' Kowalczyk
1 sibling, 0 replies; 7+ messages in thread
From: Marcin 'Qrczak' Kowalczyk @ 2001-04-29 10:14 UTC (permalink / raw)
To: caml-list
Sun, 29 Apr 2001 12:15:24 +0400 (MSD), Vitaly Lugovsky <vsl@ontil.ihep.su> pisze:
> It's "unused" and can be optimized out only when <...> is a pure
> functional statement (not changing global state).
If it's not, I would not bind its result to a variable but to _.
--
__("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Caml-list] Re: unused variables warning
2001-04-28 9:57 [Caml-list] unused variables warning Pixel
2001-04-29 8:15 ` Vitaly Lugovsky
@ 2002-09-09 21:24 ` Pixel
1 sibling, 0 replies; 7+ messages in thread
From: Pixel @ 2002-09-09 21:24 UTC (permalink / raw)
To: caml-list
I've asked the following question one year ago:
> Is there any way to ask ocamlc for an "unused variable" warning?
>
> let f x =
> let x' = <...> in
> x
>
> would issue something like
>
> File "test.ml", line 2, characters 3-18:
> Unused variable x'
I got an answer from Pascal Brisset sending me a nice incomplete piece
of code doing this. After a small adaptation, I've been using it with
3.04.
When "updating" it to 3.06, i tried to integrate in mandrake's package
to ease my use of it:
- i've added it when all warnings are enabled (-w A)
- it's quite ugly, i've added the various things to make it compile on
3.06 without knowing what should be done. At least it somewhat works :)
- i've dropped a functionality from Pascal Brisset's tool: it only
checks local variables, not modules variables&functions. It was easier
for me and does the checks I need (since my .mli are mostly
auto-generated).
- the comments from Pascal Brisset still apply
- it is uncomplete (it does not handle local modules ...)
- warning are not issued for identifiers starting with an underscore.
So if it interests someone :)
The patch on ocaml 3.06:
http://people.mandrakesoft.com/~prigaux/ocaml-3.06-add-warning-for-unused-local-variables.patch
The tool on ocaml 3.04:
http://people.mandrakesoft.com/~prigaux/warn_unused.make
http://people.mandrakesoft.com/~prigaux/warn_unused.ml
(special thanks to Pascal Brisset of course)
-------------------
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] 7+ messages in thread
end of thread, other threads:[~2002-09-09 21:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-28 9:57 [Caml-list] unused variables warning Pixel
2001-04-29 8:15 ` Vitaly Lugovsky
2001-04-29 9:58 ` Pixel
2001-04-29 13:06 ` Sven LUTHER
2001-04-29 13:14 ` Pixel
2001-04-29 10:14 ` Marcin 'Qrczak' Kowalczyk
2002-09-09 21:24 ` [Caml-list] " Pixel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox