Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: introspecti...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 28 of 103 Topic 2681 of 3057
Post > Topic >>

Re: introspection in SML

by "michele.simionato@[EMAIL PROTECTED] " <michele.simionato@[EMAIL PROTECTED] > Dec 2, 2007 at 05:53 AM

On Dec 2, 1:29 pm, Vesa Karvonen <vesa.karvo...@[EMAIL PROTECTED]
> wrote:
> Note that introspection
> is not exactly free.  Having introspection means that a lot of metadata
> needs to included in the binary and that many optimizations cannot be
> performed (or are hindered).  For example, if SML provided run-time
> introspection to allow one to iterate over the values in a structure,
you
> could not, for example, safely eliminate unused values from a structure
or
> inline a definition at all use sites and then eliminate the definition.
> The compiler also couldn't make data representation optimization, such
as
> eliminating unused fields from records or unused variants from
datatypes.
> All of the previous kind of optimizations (and more) are performed
> aggressively by MLton, for example.  So, introspection isn't just a
> blessing --- it is also a limitation.

I don't buy your argument. A few bytes spent in docstrings are a
non-issue when we all have hundreds of gigabytes of unused
disk space. And even if some dead code was not removed by
the compiler, would it matter much, in practice? I am of the
opinion that if an user wants an optimization, it should say so
explicitely with a compiler flag: by default he should not pay
the price of the optimization.

> Personally, I don't find introspection crucial.  I've used
> introspection quite heavily in Java, for example, but mostly as a
> workaround for some other deficiency.  In particular, when you have
> lightweight anonymous functions, infix operators and lightweight
> syntax for calling functions, many of the uses of introspection can be
> encoded concisely.

Yes, I understand that I can define something like

datatype ('a, 'b) function_with_docstring = FUN of ('a->'b) * string

val double = FUN (fn x => 2*x, "A function doubling its argument")

and even implement a mechanism to register all the docstrings
and possibly other informations such as names and types, but
frankly this sounds to me like a job for the language, not
for the user. As I have said before, it looks absurd to me
that information which is available to the compiler (even
if absence of a REPL the compiler knows the signatures, which
is the things which are more im****tant for a do***entation
tool, even in absence of docstrings) is hidden to the user.
And what if I wanted to code an IDE for SML? It looks
impossible without resorting to help from the underlying
implementation.

> Note that this approach is not without advantages over the ad hoc
approach
> of grepping for functions named as "test"s.  In particular, it allows
you
> to conveniently define new test registration specifiers.  See here for
an
> example:
>
> 
http://mlton.org/cgi-bin/viewsvn.cgi/*checkout*/mltonlib/trunk/com/ss...

I will look at the example, but since I am lazy I will ask
a question before. How are implemented registers in SML?
I would go with something like this

val registerList = ref []

fun register(name, function) =
  registerList := (name, function) :: ! registerList

or with a StringMap if I wanted to be able to retrieve functions
by name. However, a register works with side effects and I am told
that functional languages should avoid side effects as much as
possible; nevertheless I don't see how to avoid mutating the
reference here.

    Michele Simionato
 




 103 Posts in Topic:
introspection in SML
"michele.simionato@[  2007-12-01 22:57:46 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-02 12:29:39 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-12 04:29:43 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-12 12:09:12 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-12 19:54:28 
Re: introspection in SML
George Neuner <gneuner  2007-12-13 01:15:15 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-13 03:48:06 
Re: introspection in SML
Joachim Durchholz <jo@  2007-12-13 12:30:35 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-13 12:09:24 
Re: introspection in SML
Joachim Durchholz <jo@  2007-12-13 19:17:57 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-13 20:25:28 
.net
Joachim Durchholz <jo@  2007-12-14 10:54:42 
Re: .net
Jon Harrop <usenet@[EM  2007-12-14 10:45:26 
Re: .net
Joachim Durchholz <jo@  2007-12-14 21:30:03 
Re: .net
Jon Harrop <usenet@[EM  2007-12-14 21:55:11 
Re: .net
Paul Rubin <http://phr  2007-12-14 14:45:47 
Re: introspection in SML
George Neuner <gneuner  2007-12-13 14:23:15 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-13 11:56:14 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-14 03:43:12 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-14 09:48:46 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-15 03:22:38 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-14 19:30:15 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-16 00:15:30 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-16 03:19:46 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-16 04:32:16 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-16 16:58:45 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-16 21:26:46 
Re: introspection in SML
"michele.simionato@[  2007-12-02 05:53:58 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-02 19:21:18 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 09:13:44 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-17 00:34:20 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-17 13:42:35 
Re: introspection in SML
"michele.simionato@[  2007-12-02 22:33:29 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 08:47:26 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 13:27:12 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 15:42:47 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-04 16:06:56 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 18:35:13 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 20:37:24 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 20:26:57 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 21:46:16 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 21:49:25 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 22:59:39 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 23:24:15 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-05 00:48:18 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 15:18:29 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-05 18:26:05 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 17:43:26 
Re: introspection in SML
George Neuner <gneuner  2007-12-06 01:55:46 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 14:49:44 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-05 07:01:35 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 18:23:23 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 20:50:35 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 08:44:08 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 10:04:33 
Re: introspection in SML
"michele.simionato@[  2007-12-04 02:35:04 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 10:50:40 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 15:00:59 
Re: introspection in SML
"michele.simionato@[  2007-12-04 22:10:33 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-04 22:55:22 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 07:58:10 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-05 00:25:34 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 17:31:25 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-11 18:21:58 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-11 19:57:41 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 20:26:45 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-11 21:41:51 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 22:14:00 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-11 23:43:34 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-14 14:32:06 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-11 20:19:53 
Re: introspection in SML
Joachim Durchholz <jo@  2007-12-12 13:40:03 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 22:38:17 
Re: introspection in SML
"michele.simionato@[  2007-12-05 08:22:07 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-11 16:38:54 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-12 01:55:14 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-11 17:22:20 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-12 02:32:44 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 08:04:13 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-11 23:37:53 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 09:23:57 
Re: introspection in SML
"michele.simionato@[  2007-12-11 22:53:33 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-12 08:34:11 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-12 08:59:00 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 00:01:43 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 00:12:41 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 09:24:36 
Re: introspection in SML
"michele.simionato@[  2007-12-12 00:50:11 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 01:05:12 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 13:23:56 
Re: introspection in SML
"michele.simionato@[  2007-12-12 01:16:11 
Re: introspection in SML
"michele.simionato@[  2007-12-12 04:39:28 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-12 13:10:31 
Re: introspection in SML
"michele.simionato@[  2007-12-12 05:48:51 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-12 15:49:28 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 07:50:27 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 17:26:12 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-12 11:47:44 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 22:59:03 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 09:13:50 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 20:27:50 
Re: introspection in SML
Florian Weimer <fw@[EM  2007-12-15 13:50:58 
Re: introspection in SML
Philippa Cowderoy <fli  2007-12-16 22:06:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 8:12:42 CST 2008.