Language question -- file = variable ?

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Aug 16 14:53:25 UTC 2011


On Tue, Aug 16, 2011 at 07:41:24AM -0700, William Park wrote:
> Is there a language which (natively or not) treats a filename like a variable in memory?  For example, to increment a counter stored in a file, you would write something like
>         /tmp/counter = /tmp/counter + 1
> which involves both read and write to a file.  If it were normal variable, then it would involve read/write to a memory instead.
> 
> Python is the closest I can think of.  But, you need to create a method for read and another method for write.  And, typing more verbose than I would like.

So you want to language to open the file, read it, guess that you want
it to treat its contents as an integer/hex/whatever and add one to it,
then write it back as interger/hex/whatever and flush?

That's an awful lot of assumptions for a language to make.  I doubt any
are silly enough to try that.

How about error handling?  Disk full, file permissions, file locks, etc?
Adding 1 to a variable is something that can't fail, but if you do it to
the contents of a file it certainly can.  It's just not the same thing
at all, and the same syntax makes no sense as a result since you have
no way to do error handling with your syntax, and you will need to have
error handling for it.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list