all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Very basic questions.
@ 2006-09-15 19:07 jronald
  2006-09-16  3:40 ` John Sullivan
       [not found] ` <mailman.7000.1158379340.9609.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 12+ messages in thread
From: jronald @ 2006-09-15 19:07 UTC (permalink / raw)


How does .el run?

Is it an explanation language or a compilation one?
I know little about how explanation language works.
Take "require" for example. How does it know where the
feature list is? Or, how does feature list make itself to be found by 
functions? Maybe the problem is what is the memory model about elisp. 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Very basic questions.
@ 2006-09-15 20:22 Jay Bingham
  0 siblings, 0 replies; 12+ messages in thread
From: Jay Bingham @ 2006-09-15 20:22 UTC (permalink / raw)


On Friday, September 15, 2006 at 2:07 PM jronald wrote:

> How does .el run?

> Is it an explanation language or a compilation one?
> I know little about how explanation language works.

I am not familiar with the term "explanation language" so I did a 
search on the Internet for it and from the one reference that I found 
to "explanation language" related to programming I do not believe 
that elisp is an explanation language.  Elisp can be "compiled" or it 
can be run in interpreted mode.

> Take "require" for example. How does it know where the
> feature list is? Or, how does feature list make itself to be found
> by functions? Maybe the problem is what is the memory model about
> elisp.

"require" and "load" both locate modules by searching the load-path.

You can read about all of this in the elisp reference manual, which 
if it is not installed on your system in the info directory it can be 
found on the web.

__
J_)
C_)ingham 


_____________________________________________________________________
PrivatePhone - FREE telephone number & voicemail.
A number so private, you can make it public.
http://www.privatephone.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
       [not found] <mailman.6992.1158351893.9609.help-gnu-emacs@gnu.org>
@ 2006-09-15 20:48 ` jronald
  2006-09-15 20:50 ` jronald
  1 sibling, 0 replies; 12+ messages in thread
From: jronald @ 2006-09-15 20:48 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]

It should be "interpreted" not "explanation".
My poor english..
"Jay Bingham" <b.jc-emacs@netzero.com> дÈëÏûÏ¢ÐÂÎÅ:mailman.6992.1158351893.9609.help-gnu-emacs@gnu.org...
On Friday, September 15, 2006 at 2:07 PM jronald wrote:

> How does .el run?

> Is it an explanation language or a compilation one?
> I know little about how explanation language works.

I am not familiar with the term "explanation language" so I did a
search on the Internet for it and from the one reference that I found
to "explanation language" related to programming I do not believe
that elisp is an explanation language.  Elisp can be "compiled" or it
can be run in interpreted mode.

> Take "require" for example. How does it know where the
> feature list is? Or, how does feature list make itself to be found
> by functions? Maybe the problem is what is the memory model about
> elisp.

"require" and "load" both locate modules by searching the load-path.

You can read about all of this in the elisp reference manual, which
if it is not installed on your system in the info directory it can be
found on the web.

__
J_)
C_)ingham


_____________________________________________________________________
PrivatePhone - FREE telephone number & voicemail.
A number so private, you can make it public.
http://www.privatephone.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
       [not found] <mailman.6992.1158351893.9609.help-gnu-emacs@gnu.org>
  2006-09-15 20:48 ` Very basic questions jronald
@ 2006-09-15 20:50 ` jronald
  1 sibling, 0 replies; 12+ messages in thread
From: jronald @ 2006-09-15 20:50 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]

Then manual doesn't have any description at this level.
"Jay Bingham" <b.jc-emacs@netzero.com> дÈëÏûÏ¢ÐÂÎÅ:mailman.6992.1158351893.9609.help-gnu-emacs@gnu.org...
On Friday, September 15, 2006 at 2:07 PM jronald wrote:

> How does .el run?

> Is it an explanation language or a compilation one?
> I know little about how explanation language works.

I am not familiar with the term "explanation language" so I did a
search on the Internet for it and from the one reference that I found
to "explanation language" related to programming I do not believe
that elisp is an explanation language.  Elisp can be "compiled" or it
can be run in interpreted mode.

> Take "require" for example. How does it know where the
> feature list is? Or, how does feature list make itself to be found
> by functions? Maybe the problem is what is the memory model about
> elisp.

"require" and "load" both locate modules by searching the load-path.

You can read about all of this in the elisp reference manual, which
if it is not installed on your system in the info directory it can be
found on the web.

__
J_)
C_)ingham


_____________________________________________________________________
PrivatePhone - FREE telephone number & voicemail.
A number so private, you can make it public.
http://www.privatephone.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-15 19:07 jronald
@ 2006-09-16  3:40 ` John Sullivan
       [not found] ` <mailman.7000.1158379340.9609.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: John Sullivan @ 2006-09-16  3:40 UTC (permalink / raw)


"jronald" <followait@163.com> writes:

> Take "require" for example. 

Sorry, example of what?

> How does it know where the feature list is? Or, how does feature list make
> itself to be found by functions?

Libraries that provide features include a (provide 'foofeature).

The feature list is stored in the variable called features.

-- 
-John Sullivan
-http://www.wjsullivan.net
-GPG Key: AE8600B6

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
       [not found] ` <mailman.7000.1158379340.9609.help-gnu-emacs@gnu.org>
@ 2006-09-16 11:18   ` jronald
  2006-09-16 11:28     ` Colin S. Miller
  0 siblings, 1 reply; 12+ messages in thread
From: jronald @ 2006-09-16 11:18 UTC (permalink / raw)



"John Sullivan" <john@wjsullivan.net> 
??????:mailman.7000.1158379340.9609.help-gnu-emacs@gnu.org...
> "jronald" <followait@163.com> writes:
>
>> Take "require" for example.
>
> Sorry, example of what?
>

as below

>> How does it know where the feature list is? Or, how does feature list 
>> make
>> itself to be found by functions?
>
> Libraries that provide features include a (provide 'foofeature).
>
> The feature list is stored in the variable called features.
>

In runtime, how does "require" know where the feature list is? There is only 
machine code then.

> -- 
> -John Sullivan
> -http://www.wjsullivan.net
> -GPG Key: AE8600B6
>
>
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-16 11:18   ` jronald
@ 2006-09-16 11:28     ` Colin S. Miller
  2006-09-16 11:59       ` jronald
  0 siblings, 1 reply; 12+ messages in thread
From: Colin S. Miller @ 2006-09-16 11:28 UTC (permalink / raw)


> 
> In runtime, how does "require" know where the feature list is? There is only 
> machine code then.
> 
John,

(require 'feature)
searches the paths listed in 'load-path',
this can be added to using (add-path).
It looks for a file called "feature.el" or "feature.elc".


Emacs packages can either be in source-code,
which have an extension '.el', or be pre-compiled,
where they have the extension '.elc'.

Pre-compiled packages run faster than packages dynamically
compiled from source.

The pre-compiled emacs tends to come with its packages pre-compiled
as well, there will be sources for the packages where you got
emacs from.

HTH,
Coin S. Miller

-- 
Replace the obvious in my email address with the first three letters of the hostname to reply.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-16 11:28     ` Colin S. Miller
@ 2006-09-16 11:59       ` jronald
  2006-09-16 12:43         ` Colin S. Miller
  2006-09-18  5:42         ` Tim X
  0 siblings, 2 replies; 12+ messages in thread
From: jronald @ 2006-09-16 11:59 UTC (permalink / raw)



"Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
??????:450bdfd3$0$75037$14726298@news.sunsite.dk...
>>
>> In runtime, how does "require" know where the feature list is? There is 
>> only machine code then.
>>
> John,
>
> (require 'feature)
> searches the paths listed in 'load-path',
> this can be added to using (add-path).
> It looks for a file called "feature.el" or "feature.elc".
>
>
Do you mean that "provide" modifies the files, both .el and .elc? I just 
can't imagine.

> Emacs packages can either be in source-code,
> which have an extension '.el', or be pre-compiled,
> where they have the extension '.elc'.
>
> Pre-compiled packages run faster than packages dynamically
> compiled from source.
>
> The pre-compiled emacs tends to come with its packages pre-compiled
> as well, there will be sources for the packages where you got
> emacs from.
>
> HTH,
> Coin S. Miller
>
> -- 
> Replace the obvious in my email address with the first three letters of 
> the hostname to reply. 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-16 11:59       ` jronald
@ 2006-09-16 12:43         ` Colin S. Miller
  2006-09-16 18:13           ` jronald
  2006-09-18  5:42         ` Tim X
  1 sibling, 1 reply; 12+ messages in thread
From: Colin S. Miller @ 2006-09-16 12:43 UTC (permalink / raw)


jronald wrote:
> "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
> ??????:450bdfd3$0$75037$14726298@news.sunsite.dk...
>>> In runtime, how does "require" know where the feature list is? There is 
>>> only machine code then.
>>>
>> John,
>>
>> (require 'feature)
>> searches the paths listed in 'load-path',
>> this can be added to using (add-path).
>> It looks for a file called "feature.el" or "feature.elc".
>>
>>
> Do you mean that "provide" modifies the files, both .el and .elc? I just 
> can't imagine.
John,

(require 'feature) loads the package 'feature' into
Emacs's memory, it doesn't modify the source,
or pre-compiled package, it just reads them.

(provide 'feature),
which is at the end of 'feature.el', confirms that the
package "feature" has been loaded; this makes a subsequent
(require 'feature) a no-operation command.

A feature is normally provided by a source file
of the same name as the feature, but can
be provided by a different file, by using
(require 'feature "feature-mode")
In this cause "feature-mode.el" or "feature-mode.elc"
will be loaded, they should have a
(provide 'feature) at the end.


To compile a source package into its .elc,
run (byte-compile-file) on it. This
is done when Emacs is compiled from its sources,
and unless you are writing your own packages,
you shouldn't need to use it.

HTH,
Colin S. Miller

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-16 12:43         ` Colin S. Miller
@ 2006-09-16 18:13           ` jronald
  2006-09-16 18:42             ` Colin S. Miller
  0 siblings, 1 reply; 12+ messages in thread
From: jronald @ 2006-09-16 18:13 UTC (permalink / raw)


Thanks for your patient help.
"Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
??????:450bf16c$0$75039$14726298@news.sunsite.dk...
> jronald wrote:
>> "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
>> ??????:450bdfd3$0$75037$14726298@news.sunsite.dk...
>>>> In runtime, how does "require" know where the feature list is? There is 
>>>> only machine code then.
>>>>
>>> John,
>>>
>>> (require 'feature)
>>> searches the paths listed in 'load-path',
>>> this can be added to using (add-path).
>>> It looks for a file called "feature.el" or "feature.elc".
>>>
>>>
>> Do you mean that "provide" modifies the files, both .el and .elc? I just 
>> can't imagine.
> John,
>
> (require 'feature) loads the package 'feature' into
> Emacs's memory, it doesn't modify the source,
> or pre-compiled package, it just reads them.
>
"require" will find check if the feature already there first, and "provide" 
will add a feature to the feature list.
How do they find the feature list? Or how do they know the memory location 
where feature list is?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-16 18:13           ` jronald
@ 2006-09-16 18:42             ` Colin S. Miller
  0 siblings, 0 replies; 12+ messages in thread
From: Colin S. Miller @ 2006-09-16 18:42 UTC (permalink / raw)


jronald wrote:
> Thanks for your patient help.
> "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
>> John,
>>
>> (require 'feature) loads the package 'feature' into
>> Emacs's memory, it doesn't modify the source,
>> or pre-compiled package, it just reads them.
>>
> "require" will find check if the feature already there first, and "provide" 
> will add a feature to the feature list.
> How do they find the feature list? Or how do they know the memory location 
> where feature list is?
> 
> 

John,

The help for "require", accessed by
C-h f require RET
states
`require' (buffer: *Hyper Apropos*, mode: Hyper-Apropos)


Compiled Lisp function,
(loaded from "poe"):

   arguments: (feature &optional filename noerror)

   If feature FEATURE is not loaded, load it from FILENAME.
   If FEATURE is not a member of the list `features', then the feature
   is not loaded; so load the file FILENAME.
   If FILENAME is omitted, the printname of FEATURE is used as the file name,
   but in this case `load' insists on adding the suffix `.el' or `.elc'.
   If the optional third argument NOERROR is non-nil,
   then return nil if the file is not found.
   Normally the return value is FEATURE.



The variable "features" gives a list of loaded features,
there is no list of available, unloaded features.

For example,
M-: (require 'foobar)

reports, after checking each directory listed in the load-path variable.
"Error: file-error; Data: (Cannot open load file foobar)"

You can use
C-h v load-path
to obtain a list of the paths that Emacs will search.


The keyboard sequence M-:  (alt :   on most keyboards)
allows you to evaluate (run) any lisp expression,
here I tried to require a non-existent feature.

Each time you call (require) Emacs searches the load-path
for a filename matching the feature you are attempting to require.

HTH,
Colin S. Miller


-- 
Replace the obvious in my email address with the first three letters of the hostname to reply.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Very basic questions.
  2006-09-16 11:59       ` jronald
  2006-09-16 12:43         ` Colin S. Miller
@ 2006-09-18  5:42         ` Tim X
  1 sibling, 0 replies; 12+ messages in thread
From: Tim X @ 2006-09-18  5:42 UTC (permalink / raw)


"jronald" <followait@163.com> writes:

> "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> 
> ??????:450bdfd3$0$75037$14726298@news.sunsite.dk...
>>>
>>> In runtime, how does "require" know where the feature list is? There is 
>>> only machine code then.
>>>
>> John,
>>
>> (require 'feature)
>> searches the paths listed in 'load-path',
>> this can be added to using (add-path).
>> It looks for a file called "feature.el" or "feature.elc".
>>
>>
> Do you mean that "provide" modifies the files, both .el and .elc? I just 
> can't imagine.
>
>> Emacs packages can either be in source-code,
>> which have an extension '.el', or be pre-compiled,
>> where they have the extension '.elc'.
>>
>> Pre-compiled packages run faster than packages dynamically
>> compiled from source.
>>
>> The pre-compiled emacs tends to come with its packages pre-compiled
>> as well, there will be sources for the packages where you got
>> emacs from.
>>
>> HTH,
>> Coin S. Miller
>>
>> -- 
>> Replace the obvious in my email address with the first three letters of 
>> the hostname to reply. 
>
>

John, 

I htink your over thinking this whole issue. Its very basic really. 

When you create an emacs lisp package, you add the following line.
Often it is added at the end of the file so that it doesn't run unless
the file loads correctly

(provide 'feature)

where 'feature is some symbol/name that reflects what is provided by
the code in that file. When this file is loaded, emacs will keep track
of this information and will know that this "feature" has been added.

The other side of the coin is "require', usually put at the top of a
file and indicates some feature or support library your code will
require, for example

(require 'feature)

When you load a file with this requirement into emacs, it will first
check to see if the feature has already been loaded (see C-h f
featurep for details of a predicate that can be used to determine if a
feature has been loaded). If the feature/library has not been loaded,
emacs will search the load-path for a file called feature.el or
feature.elc. If it finds one, it will load that file - note that that
file may also include more require statements, resulting in other
files being loaded. 

This whole mechanism is a bit similar to using C macros to ensure
header files are loaded and only loaded once. In a C header file
feature.h, you might have a line like

#define _FEATURE_H_ 

and in one of your other .c or .h files, you might have a line like

#ifndef _FEATURE_H_
#include "feature.h"
#endif

The issues regarding whether the files are byte compiled or just
interpreted are pretty much irrelevant and can be ignored with respect
to this mechanism. 

HTH

Tim


-- 
tcross (at) rapttech dot com dot au

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-09-18  5:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.6992.1158351893.9609.help-gnu-emacs@gnu.org>
2006-09-15 20:48 ` Very basic questions jronald
2006-09-15 20:50 ` jronald
2006-09-15 20:22 Jay Bingham
  -- strict thread matches above, loose matches on Subject: below --
2006-09-15 19:07 jronald
2006-09-16  3:40 ` John Sullivan
     [not found] ` <mailman.7000.1158379340.9609.help-gnu-emacs@gnu.org>
2006-09-16 11:18   ` jronald
2006-09-16 11:28     ` Colin S. Miller
2006-09-16 11:59       ` jronald
2006-09-16 12:43         ` Colin S. Miller
2006-09-16 18:13           ` jronald
2006-09-16 18:42             ` Colin S. Miller
2006-09-18  5:42         ` Tim X

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.