[erlang-questions] What atom name to represent a null value

Jayson Vantuyl kagato@REDACTED
Fri Feb 26 01:53:15 CET 2010


I don't believe that it's defined explicitly, but it's the standard API of many functions.  For example:

* when accessing the process dictionary, if the key doesn't exist, the value is undefined; try: get(foo), or erase(foo)
* when accessing a proplist for a key that doesn't exist, the value is undefined; try: proplists:get_value(foo,[])
* when looking for a registered name that isn't registered, the value is undefined: try: whereis(foo)
* erlang:decode_packet/3 returns undefined when the length of a packet is unknown
* erlang:delete_module/1 returns undefined when you delete a module that isn't loaded
* erlang:port_info/2 returns undefined on a nonexistent port
* erlang:process_info/1 returns undefined on a nonexistent process
* erlang:system_monitor/1 takes undefined as an argument, meaning to set null monitoring settings
* file:pid2name/1 gives undefined if a pid isn't associated with a filename

It's all over the libraries.  Conversely, I can't find none, null, or nil anywhere.  Of course, I didn't look too hard.

Given the overwhelming use of undefined in Erlang itself, I think it's safe to use in your code to represent a null value.

On Feb 25, 2010, at 4:33 PM, caio ariede wrote:

> Right.
> 
> It is defined in somewhere? Some documentation?
> 
> Or just in common sense?
> 
> Thanks
> 
> Caio Ariede
> http://caioariede.com/
> 
> 
> On Thu, Feb 25, 2010 at 9:29 PM, Jayson Vantuyl <kagato@REDACTED> wrote:
> 
>> undefined is the standard one.  Although I've used none, null, and nil
>> before (in different situations).
>> 
>> On Feb 25, 2010, at 4:20 PM, caio ariede wrote:
>> 
>>> I already saw some people using "undef", but I want to know what name is
>>> commonly used (if there is).
>>> 
>>> Caio Ariede
>>> http://caioariede.com/
>>> 
>>> 
>>> On Thu, Feb 25, 2010 at 9:14 PM, David Lloyd <lloy0076@REDACTED>
>> wrote:
>>> 
>>>> 
>>>> Why couldn't you use "null"?
>>>> 
>>>> DSL
>>>> 
>>>> -----Original Message-----
>>>> *From*: caio ariede <caio.ariede@REDACTED<
>> caio%20ariede%20%3ccaio.ariede@REDACTED<caio%2520ariede%2520%253ccaio.ariede@REDACTED>
>> %3e>
>>>>> 
>>>> *To*: erlang-questions <erlang-questions@REDACTED<
>> erlang-questions%20%3cerlang-questions@REDACTED<erlang-questions%2520%253cerlang-questions@REDACTED>
>> %3e>
>>>>> 
>>>> *Subject*: [erlang-questions] What atom name to represent a null value
>>>> *Date*: Thu, 25 Feb 2010 21:13:34 -0300
>>>> 
>>>> In common sense, what atom name can I use to better represent null
>> values?
>>>> 
>>>> Thanks.
>>>> 
>>>> Caio Ariedehttp://caioariede.com/
>>>> 
>>>> 
>>>> 
>> 
>> --
>> Jayson Vantuyl
>> kagato@REDACTED
>> 
>> 
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>> 
>> 

-- 
Jayson Vantuyl
kagato@REDACTED



More information about the erlang-questions mailing list