Package support in Erlang: Status ?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Mickael Remond-2
Hello,

I would like to know what is the current status of packages in Erlang
?

During the last Erlang User Conference, I had the feeling that the use
of package for erlang development was here for feedback from the
developers but not yet really approved for industrial project.

I do not feel conformtable yet with the package development as it
requires to change the syntax for standard module call (You need to
use the prefix . to specify that you are refering to the root
package).
This means that code need to be modified to work with packages.

What is the current status ? I have seen that Erik Reitsma was using
them successfully in the Erlang SOAP module.
Does other developers have adopted it already ? Should the developer
use it for new development ?

--
Micka?l R?mond
http://www.erlang-projects.org/



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Richard Carlsson-4
----- Original Message -----
From: "Mickael Remond" <mickael.remond>
To: <erlang-questions>
Sent: Friday, April 18, 2003 5:28 PM
Subject: Package support in Erlang: Status ?


> I would like to know what is the current status of packages in Erlang
>
> During the last Erlang User Conference, I had the feeling that the use
> of package for erlang development was here for feedback from the
> developers but not yet really approved for industrial project.

The OTP people have said that the package system is included for evaluation,
and if it turns out that people (i.e., you who are reading this) don't like
it, it
could be removed again. So it's up to you.

So far I've had almost no feedback at all from users, so if you read this
and
have tried using packages, then please do let everybody know what you think!

> I do not feel conformtable yet with the package development as it
> requires to change the syntax for standard module call (You need to
> use the prefix . to specify that you are refering to the root
> package).

The much preferred method is to simply add an 'import' statement at the
top of the module. So e.g, if you want to call the standard library 'lists'
module from within a module in a package:

        -module(com.bigcorp.foo).
        ...
        -import(lists).
        ...
        f(X) -> ... lists:reverse(...) ...

will call 'lists:reverse(...)' instead of the default
'com.bigcorp.lists:reverse(...)'.
The prefix form '.lists:reverse(...)' could also be used, as you mention,
but this
is more of a "final resort" solution (if the imported name is already used),
or
could be used if you have a one-shot call to some module and don't feel like
adding an import statement, but the -import(...) makes it less error prone.

So, if you want to move code from the current "flat" namespace into a
package namespace, you have to:

        1. rename the module, by prefixing a package name
        2. add an '-import(Mod)' for each non-package Mod that is being
called.

and that's it. Note that existing code can call package modules without any
changes - for example, you can give a module name as
'com.bigcorp.mycallback'
to the good old gen_server, and everything works just as normal.

The only real problem I currently know of is the debugger, which has a hard
time
with the fact that the source file name is not the same as the full module
name. I hope
I can fix this for the coming R9C release, or just mail a patch to this
list.

    /Richard



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Vladimir Sekissov
Good day,

richardc> So far I've had almost no feedback at all from users, so if you read this
richardc> and
richardc> have tried using packages, then please do let everybody know what you think!

I'm using packages and like them a lot so here is my vote for them.

Best Regards,
Vladimir Sekissov


Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Ulf Wiger (AL/EAB)
In reply to this post by Richard Carlsson-4
>         -module(com.bigcorp.foo).
>         ...
>         -import(lists).
>         ...
>         f(X) -> ... lists:reverse(...) ...
>
> will call 'lists:reverse(...)' instead of the default
> 'com.bigcorp.lists:reverse(...)'.


I sent a suggestion for a patch to the linter to erlang-patches
the other day (no cc to erlang-questions) though. This patch
makes the linter issue a warning if it encounters e.g. lists:reverse(...),
and there is (a) no '-import(lists).' statement in the module, and
(b) there is no lists.beam (presumably comp.bigcorp.lists) in the
outdir directory.

I've found this to be one of the most common errors related to the
the use of packages. With this warning in place, I feel that adding
-import clauses does not cause me any problems at all, and the
linter will remind me if I've forgotten one.

/Uffe

----- Original Message -----
From: "Richard Carlsson" <richardc>
To: <erlang-questions>; "Mickael Remond"
<mickael.remond>
Sent: den 19 april 2003 12:54
Subject: Re: Package support in Erlang: Status ?


> ----- Original Message -----
> From: "Mickael Remond" <mickael.remond>
> To: <erlang-questions>
> Sent: Friday, April 18, 2003 5:28 PM
> Subject: Package support in Erlang: Status ?
>
>
> > I would like to know what is the current status of packages in Erlang
> >
> > During the last Erlang User Conference, I had the feeling that the use
> > of package for erlang development was here for feedback from the
> > developers but not yet really approved for industrial project.
>
> The OTP people have said that the package system is included for
evaluation,
> and if it turns out that people (i.e., you who are reading this) don't
like
> it, it
> could be removed again. So it's up to you.
>
> So far I've had almost no feedback at all from users, so if you read this
> and
> have tried using packages, then please do let everybody know what you
think!
>
> > I do not feel conformtable yet with the package development as it
> > requires to change the syntax for standard module call (You need to
> > use the prefix . to specify that you are refering to the root
> > package).
>
> The much preferred method is to simply add an 'import' statement at the
> top of the module. So e.g, if you want to call the standard library
'lists'

> module from within a module in a package:
>
>         -module(com.bigcorp.foo).
>         ...
>         -import(lists).
>         ...
>         f(X) -> ... lists:reverse(...) ...
>
> will call 'lists:reverse(...)' instead of the default
> 'com.bigcorp.lists:reverse(...)'.
> The prefix form '.lists:reverse(...)' could also be used, as you mention,
> but this
> is more of a "final resort" solution (if the imported name is already
used),
> or
> could be used if you have a one-shot call to some module and don't feel
like
> adding an import statement, but the -import(...) makes it less error
prone.
>
> So, if you want to move code from the current "flat" namespace into a
> package namespace, you have to:
>
>         1. rename the module, by prefixing a package name
>         2. add an '-import(Mod)' for each non-package Mod that is being
> called.
>
> and that's it. Note that existing code can call package modules without
any
> changes - for example, you can give a module name as
> 'com.bigcorp.mycallback'
> to the good old gen_server, and everything works just as normal.
>
> The only real problem I currently know of is the debugger, which has a
hard
> time
> with the fact that the source file name is not the same as the full module
> name. I hope
> I can fix this for the coming R9C release, or just mail a patch to this
> list.
>
>     /Richard
>



Reply | Threaded
Open this post in threaded view
|

Yaws Emacs Mode?

Steven Gravell-2
Is there Yaws Emacs mode that highlights both HTML and Erlang?

If so, where might I find it?

If not, what are other folks doing?

Steve
--
  _    Steven H. Rogers, PhD.
<_`   email: steve
|_>   Weblog http://shrogers.com/zope/portal/Members/steve/blog
| \   "A language that doesn't affect the way you think about
       programming is not worth knowing." - Alan Perlis



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Ulf Wiger (AL/EAB)
In reply to this post by Richard Carlsson-4
From: "Richard Carlsson" <richardc>

> So far I've had almost no feedback at all from users, so if you read this
> and
> have tried using packages, then please do let everybody know what you
think!

I'm using packages, and am fairly positive so far. I don't think there are
many
drawbacks, and the package concept does solve the problem of module
name space -- I find that a great relief.

I have suggested a patch to the release handler (systools_make) that makes
it able to build boot scripts even if package names are used. I have noted
that embedded mode code loading doesn't work, and that this is due to
the fact that erl_prim_loader does not regognize packages. This module is
special, in that it's statically linked into the Erlang VM; otherwise, the
problem
is not difficult to fix.

I have also privately suggested that Erlang allow "dotted atoms" (that is,
without single quotes) in other places as well, e.g. in registered names,
ets tables, etc. This would make package support feel a little less like an
afterthought, and more like an integrated part of the language.

/Uffe



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Thomas Lindgren-5
In reply to this post by Richard Carlsson-4

--- Richard Carlsson <richardc> wrote:
> So far I've had almost no feedback at all from
> users, so if you read this
> and
> have tried using packages, then please do let
> everybody know what you think!
/.../

> So, if you want to move code from the current "flat"
> namespace into a
> package namespace, you have to:
>
>         1. rename the module, by prefixing a package
> name
>         2. add an '-import(Mod)' for each
> non-package Mod that is being
> called.
>
> and that's it. Note that existing code can call
> package modules without any
> changes - for example, you can give a module name as
> 'com.bigcorp.mycallback'
> to the good old gen_server, and everything works
> just as normal.

I tried using packages in my optimizer (granted, a
somewhat unusual application, but one that tends to
encounter these sorts of issues) and ran into a
problem with atoms used as module names.

In particular, the following two functions are not
equivalent in a "packaged" module foo.bar
(try erlc -E):

-module(foo.bar).
-compile(export_all).

f1() -> m:f(X).

f2() -> Mod = m, Mod:f(X).

As I understand your papers, this is intentional. But
it also breaks referential transparency: one (compiler
or developer) can no longer just replace occurrences
of Mod with its value m (or in general, a variable
occurrence X with the value of X).

That spells needless semantic trouble for all
involved, in my experience. So, my suggestion is to
fix that undesirable feature interaction.

Best,
Thomas


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com


Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Joe Williams-2
In reply to this post by Ulf Wiger (AL/EAB)
>
> I have also privately suggested that Erlang allow "dotted atoms" (that is,
> without single quotes) in other places as well, e.g. in registered names,
> ets tables, etc. This would make package support feel a little less like an
> afterthought, and more like an integrated part of the language.
>

There goes the dot - I'd have liked the dot for "proper" structs -
(fortunately there is still ^ and ?)

/Joe


> /Uffe
>



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Richard Carlsson-4
In reply to this post by Ulf Wiger (AL/EAB)

On Sun, 20 Apr 2003, Wiger Ulf wrote:

> I have also privately suggested that Erlang allow "dotted atoms" (that
> is, without single quotes) in other places as well, e.g. in registered
> names, ets tables, etc. This would make package support feel a little
> less like an afterthought, and more like an integrated part of the
> language.

You mean like this?:

        1> register(self(), fee.fie.foo).
        ok
        2> whereis(fee.fie.foo).
        <0.31.0>

It's already there, if you try it. If you find some example of where it
does not work, please report it to me.

        /Richard


Richard Carlsson (richardc)   (This space intentionally left blank.)
E-mail: Richard.Carlsson WWW: http://user.it.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham


Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Ulf Wiger-4
On Tue, 22 Apr 2003, Richard Carlsson wrote:

>
>On Sun, 20 Apr 2003, Wiger Ulf wrote:
>
>> I have also privately suggested that Erlang allow
>> "dotted atoms" (that is, without single quotes) in other
>> places as well, e.g. in registered names, ets tables,
>> etc. This would make package support feel a little less
>> like an afterthought, and more like an integrated part of
>> the language.
>
>You mean like this?:
>
> 1> register(self(), fee.fie.foo).
> ok
> 2> whereis(fee.fie.foo).
> <0.31.0>
>
>It's already there, if you try it. If you find some example
>of where it does not work, please report it to me.

<blush/> I admit that I hadn't tried it. Moot point then.

/Uffe
--
Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson AB, Connectivity and Control Nodes



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

david wallin-2
In reply to this post by Richard Carlsson-4



On Tuesday, April 22, 2003, at 12:45 PM, Richard Carlsson wrote:

>
> On Sun, 20 Apr 2003, Wiger Ulf wrote:
>
>> I have also privately suggested that Erlang allow "dotted atoms" (that
>> is, without single quotes) in other places as well, e.g. in registered
>> names, ets tables, etc. This would make package support feel a little
>> less like an afterthought, and more like an integrated part of the
>> language.
>
> You mean like this?:
>
> 1> register(self(), fee.fie.foo).
> ok
> 2> whereis(fee.fie.foo).
> <0.31.0>
>
> It's already there, if you try it. If you find some example of where it
> does not work, please report it to me.
>

Richard,

How about this, do a file:consult/1 on a file containing :

{abba_a,a}.
{abba.b,b}.

This results in an error : '{error,{1,erl_parse,"bad term"}}'


cheers,

--david.



Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Richard Carlsson-4
Thanks. I'll look into it.
    /Richard

----- Original Message -----
From: "david wallin" <david.wallin>
To: "Richard Carlsson" <richardc>
Cc: <erlang-questions>; "Wiger Ulf" <ulf.wiger>
Sent: Thursday, May 22, 2003 6:25 PM
Subject: Re: Package support in Erlang: Status ?


> How about this, do a file:consult/1 on a file containing :
>
> {abba_a,a}.
> {abba.b,b}.
>
> This results in an error : '{error,{1,erl_parse,"bad term"}}'
>
>
> cheers,
>
> --david.
>
>
>


Reply | Threaded
Open this post in threaded view
|

Package support in Erlang: Status ?

Richard Carlsson-4
In reply to this post by david wallin-2

On Thu, 22 May 2003, david wallin wrote:

> How about this, do a file:consult/1 on a file containing :
>
> {abba_a,a}.
> {abba.b,b}.
>
> This results in an error : '{error,{1,erl_parse,"bad term"}}'

Found it - the function erl_parse:normalise/1 did not understand the dot
notation. Below is a patch, which also fixes another latent bug.

        /Richard



*** lib/stdlib/src/erl_parse.yrl 16 May 2003 12:15:16 -0000 1.13
--- lib/stdlib/src/erl_parse.yrl 26 May 2003 16:12:09 -0000
***************
*** 511,523 ****

  package_segments(Name) ->
!     package_segments(Name, []).

! package_segments({record_field,_,F1,F2}, Fs) ->
!     package_segments(F1, [F2 | Fs]);
! package_segments({atom,La,A}, [F | Fs]) ->
!     [A | package_segments(F, Fs)];
! package_segments({atom,La,A}, []) ->
!     [A];
! package_segments(_, _) ->
      error.

--- 511,523 ----

  package_segments(Name) ->
!     package_segments(Name, [], []).

! package_segments({record_field, _, F1, F2}, Fs, As) ->
!     package_segments(F1, [F2 | Fs], As);
! package_segments({atom, _, A}, [F | Fs], As) ->
!     package_segments(F, Fs, [A | As]);
! package_segments({atom, _, A}, [], As) ->
!     lists:reverse([A | As]);
! package_segments(_, _, _) ->
      error.

***************
*** 581,584 ****
--- 581,590 ----
  normalise({tuple,_,Args}) ->
      list_to_tuple(normalise_list(Args));
+ %% Atom dot-notation, as in 'foo.bar.baz'
+ normalise({record_field,_,_,_}=A) ->
+     case package_segments(A) of
+ error -> erlang:fault({badarg, A});
+ As -> list_to_atom(packages:concat(As))
+     end;
  %% Special case for unary +/-.
  normalise({op,_,'+',{char,_,I}}) -> I;
***************
*** 587,591 ****
  normalise({op,_,'-',{char,_,I}}) -> -I; %Weird, but compatible!
  normalise({op,_,'-',{integer,_,I}}) -> -I;
! normalise({op,_,'-',{float,_,F}}) -> -F.

  normalise_list([H|T]) ->
--- 593,598 ----
  normalise({op,_,'-',{char,_,I}}) -> -I; %Weird, but compatible!
  normalise({op,_,'-',{integer,_,I}}) -> -I;
! normalise({op,_,'-',{float,_,F}}) -> -F;
! normalise(X) -> erlang:fault({badarg, X}).

  normalise_list([H|T]) ->







Richard Carlsson (richardc)   (This space intentionally left blank.)
E-mail: Richard.Carlsson WWW: http://user.it.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham