Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.lisp > #32970 > unrolled thread
| Started by | Sai Sai <sairussuria@gmail.com> |
|---|---|
| First post | 2019-05-28 07:10 -0700 |
| Last post | 2019-05-29 11:46 -0700 |
| Articles | 20 on this page of 23 — 9 participants |
Back to article view | Back to comp.lang.lisp
new functions defined list Sai Sai <sairussuria@gmail.com> - 2019-05-28 07:10 -0700
Re: new functions defined list "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-28 19:35 +0200
Re: new functions defined list Sai Sai <sairussuria@gmail.com> - 2019-05-28 10:45 -0700
Re: new functions defined list Spiros Bousbouras <spibou@gmail.com> - 2019-05-28 18:00 +0000
Re: new functions defined list Spiros Bousbouras <spibou@gmail.com> - 2019-05-28 17:50 +0000
Re: new functions defined list Sai Sai <sairussuria@gmail.com> - 2019-05-28 11:01 -0700
Re: new functions defined list Sai Sai <sairussuria@gmail.com> - 2019-05-28 11:12 -0700
Re: new functions defined list "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-28 20:22 +0200
Re: new functions defined list Spiros Bousbouras <spibou@gmail.com> - 2019-05-28 19:20 +0000
Re: new functions defined list "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-28 21:53 +0200
Re: new functions defined list Spiros Bousbouras <spibou@gmail.com> - 2019-05-28 20:34 +0000
Re: new functions defined list paul wallich <pw@panix.com> - 2019-05-28 21:03 -0400
Re: new functions defined list Kaz Kylheku <847-115-0292@kylheku.com> - 2019-05-29 17:09 +0000
Re: new functions defined list "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-29 20:40 +0200
Re: new functions defined list Madhu <enometh@meer.net> - 2019-05-29 06:43 +0530
Re: new functions defined list rpw3@rpw3.org (Rob Warnock) - 2019-05-31 15:50 +0000
Re: new functions defined list paul wallich <pw@panix.com> - 2019-05-28 14:28 -0400
Re: new functions defined list Sai Sai <sairussuria@gmail.com> - 2019-05-28 11:53 -0700
Re: new functions defined list Spiros Bousbouras <spibou@gmail.com> - 2019-05-28 19:07 +0000
Re: new functions defined list taruss@google.com - 2019-05-28 15:10 -0700
Re: new functions defined list smh <shaflich@gmail.com> - 2019-05-29 04:00 -0700
Re: new functions defined list "Pascal J. Bourguignon" <pjb@informatimago.com> - 2019-05-28 20:13 +0200
Re: new functions defined list taruss@google.com - 2019-05-29 11:46 -0700
Page 1 of 2 [1] 2 Next page →
| From | Sai Sai <sairussuria@gmail.com> |
|---|---|
| Date | 2019-05-28 07:10 -0700 |
| Subject | new functions defined list |
| Message-ID | <05ea985c-6cf6-4532-bc90-caec8c483c76@googlegroups.com> |
Well Hello everybody, I am loading a test file from test.lisp with some defuns inside supose defun1 defun2 defun3. Once the file loaded Are there a func to obtain the new functions loaded??? Thank you to evreyone for each answer.
[toc] | [next] | [standalone]
| From | "Pascal J. Bourguignon" <pjb@informatimago.com> |
|---|---|
| Date | 2019-05-28 19:35 +0200 |
| Message-ID | <m2v9xu32ip.fsf@despina.home> |
| In reply to | #32970 |
Sai Sai <sairussuria@gmail.com> writes: > Well Hello everybody, I am loading a test file from test.lisp with > some defuns inside supose defun1 defun2 defun3. Once the file loaded > Are there a func to obtain the new functions loaded??? > > Thank you to evreyone for each answer. No, but you could write one. -- __Pascal J. Bourguignon__ http://www.informatimago.com
[toc] | [prev] | [next] | [standalone]
| From | Sai Sai <sairussuria@gmail.com> |
|---|---|
| Date | 2019-05-28 10:45 -0700 |
| Message-ID | <17f410fd-4865-4a2b-acb8-c11c51c824cf@googlegroups.com> |
| In reply to | #32971 |
Hello Pascal... how can I write it. I'm very new, I think that dont know to much to do yet. I think in this... (newfunctions) => (fun1 fun2 fun3)
[toc] | [prev] | [next] | [standalone]
| From | Spiros Bousbouras <spibou@gmail.com> |
|---|---|
| Date | 2019-05-28 18:00 +0000 |
| Message-ID | <agX5cNkPaSHiCHjuz4pOQW6@bongo-ra.co> |
| In reply to | #32972 |
On Tue, 28 May 2019 10:45:13 -0700 (PDT)
Sai Sai <sairussuria@gmail.com> wrote:
> Hello Pascal... how can I write it. I'm very new, I think that dont know
> to much to do yet.
It's not an easy job so I wouldn't recommend it for a beginner. Just deciding
precisely what you want is a non trivial task in its own right. Let's say
for example that the user has defined a macro which expands into a DEFUN
{and possibly other stuff}. Would you want functions defined this way to be
included in your list ? Also DEFSTRUCT automatically defines accessor functions.
Do you want these to be included ? These off the top of my head but I'm sure
there are other more exotic ways of defining functions in CL.
> I think in this... (newfunctions) => (fun1 fun2 fun3)
Wouldn't you want an interface like (newfunctions some-file) ?
[toc] | [prev] | [next] | [standalone]
| From | Spiros Bousbouras <spibou@gmail.com> |
|---|---|
| Date | 2019-05-28 17:50 +0000 |
| Message-ID | <agX5cNkPaSHiCHjuz4pOQW6J1fws4@bongo-ra.co> |
| In reply to | #32970 |
On Tue, 28 May 2019 07:10:27 -0700 (PDT)
Sai Sai <sairussuria@gmail.com> wrote:
> Well Hello everybody, I am loading a test file from test.lisp with some
> defuns inside supose defun1 defun2 defun3. Once the file loaded Are there
> a func to obtain the new functions loaded???
Not a portable way. Common Lisp implementations in general do not store
where or how a function was defined {it could be on the REPL for example}.
Perhaps some implementations do so as an extension but I don't know of
a specific example.
[toc] | [prev] | [next] | [standalone]
| From | Sai Sai <sairussuria@gmail.com> |
|---|---|
| Date | 2019-05-28 11:01 -0700 |
| Message-ID | <d9914612-ee60-4a46-a938-de9bc5df8e62@googlegroups.com> |
| In reply to | #32973 |
Thanks Spiros :(
[toc] | [prev] | [next] | [standalone]
| From | Sai Sai <sairussuria@gmail.com> |
|---|---|
| Date | 2019-05-28 11:12 -0700 |
| Message-ID | <ea5d4de3-5795-462a-b037-a2c6fb243bce@googlegroups.com> |
| In reply to | #32973 |
But wait a minute... supose that I (defun fact... << factorial>>) in a file "test.lisp" then (load 'test.lisp) the function fact is in some place, because i write (fact 5) any time's and the interpreter returns =>120. There should be a function that return the functions loaded from a file. Obviously when I quit CLISP all my functions loaded from a file will be lost.
[toc] | [prev] | [next] | [standalone]
| From | "Pascal J. Bourguignon" <pjb@informatimago.com> |
|---|---|
| Date | 2019-05-28 20:22 +0200 |
| Message-ID | <m2muj630ct.fsf@despina.home> |
| In reply to | #32976 |
Sai Sai <sairussuria@gmail.com> writes: > There should be a function that return the functions loaded from a file. No, there should not. It is useless. > Obviously when I quit CLISP all my functions loaded from a file will be lost. Then don't quit clisp! Seriously! Never quit emacs or lisp, wait for linux to crash, or to have to reboot for upgrades. Seriously. For example, I have an emacs with this uptime: Up 73d 7h 27m 47s (Sat 2019-03-16 11:53:37), 14 buffers, 0 files -- __Pascal J. Bourguignon__ http://www.informatimago.com
[toc] | [prev] | [next] | [standalone]
| From | Spiros Bousbouras <spibou@gmail.com> |
|---|---|
| Date | 2019-05-28 19:20 +0000 |
| Message-ID | <gX5cNkPaSHiCHjuz4pOQW6J1f5@bongo-ra.co> |
| In reply to | #32978 |
On Tue, 28 May 2019 20:22:42 +0200
"Pascal J. Bourguignon" <pjb@informatimago.com> wrote:
> Sai Sai <sairussuria@gmail.com> writes:
>
> > There should be a function that return the functions loaded from a file.
>
> No, there should not. It is useless.
It's not useless , one might want to know for general information if nothing
else. But I can think of other similar but more useful things like , given a
function name , to know if it was defined in a file and if yes on which line.
> > Obviously when I quit CLISP all my functions loaded from a file will be lost.
>
> Then don't quit clisp! Seriously! Never quit emacs or lisp,
There are occasions when one wants to start from a predictable initial state.
Also one might not have exclusive use of a computer {like in an academic
environment} in which case one might quit all of his applications before
logging out.
[toc] | [prev] | [next] | [standalone]
| From | "Pascal J. Bourguignon" <pjb@informatimago.com> |
|---|---|
| Date | 2019-05-28 21:53 +0200 |
| Message-ID | <m2imtu2w5x.fsf@despina.home> |
| In reply to | #32982 |
Spiros Bousbouras <spibou@gmail.com> writes: > On Tue, 28 May 2019 20:22:42 +0200 > "Pascal J. Bourguignon" <pjb@informatimago.com> wrote: >> Sai Sai <sairussuria@gmail.com> writes: >> >> > There should be a function that return the functions loaded from a file. >> >> No, there should not. It is useless. > > It's not useless , one might want to know for general information if nothing > else. But I can think of other similar but more useful things like , given a > function name , to know if it was defined in a file and if yes on which line. Which is a different question, but similarly ill-defined. Functions are not defined "in" a file. They're defined by evaluating some forms (defun and defgeneric are only two of them). Evaluation is not done in files, it's done in environments. -- __Pascal J. Bourguignon__ http://www.informatimago.com
[toc] | [prev] | [next] | [standalone]
| From | Spiros Bousbouras <spibou@gmail.com> |
|---|---|
| Date | 2019-05-28 20:34 +0000 |
| Message-ID | <hbgNkPaSHiCHjuz4pOQW6J1fws@bongo-ra.co> |
| In reply to | #32983 |
On Tue, 28 May 2019 21:53:14 +0200 "Pascal J. Bourguignon" <pjb@informatimago.com> wrote: > Spiros Bousbouras <spibou@gmail.com> writes: > > > On Tue, 28 May 2019 20:22:42 +0200 > > "Pascal J. Bourguignon" <pjb@informatimago.com> wrote: > >> Sai Sai <sairussuria@gmail.com> writes: > >> > >> > There should be a function that return the functions loaded from a file. > >> > >> No, there should not. It is useless. > > > > It's not useless , one might want to know for general information if nothing > > else. But I can think of other similar but more useful things like , given a > > function name , to know if it was defined in a file and if yes on which line. > > Which is a different question, but similarly ill-defined. It is ill-defined but could be made precisely defined with sufficient iterations of coding or discussion. And that of course would be very much in the spirit of CL. The specific functionality I have in mind is that you could get an implementation , when doing a COMPILE-FILE or LOAD , to also generate a ctags file with the position of the various DEFUN , DEFCLASS , etc. encountered ; it would be configurable for which constructs to generate entries. This would be very useful. > Functions are > not defined "in" a file. They're defined by evaluating some forms > (defun and defgeneric are only two of them). And one way to evaluate these forms is to read them from a file. So if a function was defined by evaluating a DEFUN form which started on line N of file F then we can say that the function was defined in file F and the definition started on line N.
[toc] | [prev] | [next] | [standalone]
| From | paul wallich <pw@panix.com> |
|---|---|
| Date | 2019-05-28 21:03 -0400 |
| Message-ID | <qcklpb$b0t$1@reader2.panix.com> |
| In reply to | #32982 |
On 5/28/19 3:20 PM, Spiros Bousbouras wrote: > On Tue, 28 May 2019 20:22:42 +0200 > "Pascal J. Bourguignon" <pjb@informatimago.com> wrote: >> Sai Sai <sairussuria@gmail.com> writes: >> >>> There should be a function that return the functions loaded from a file. >> >> No, there should not. It is useless. > > It's not useless , one might want to know for general information if nothing > else. But I can think of other similar but more useful things like , given a > function name , to know if it was defined in a file and if yes on which line. Back in the Old Days, you could mouse over pretty much anything, perform the proper incantation/buttoning and come up either on the source-file line where something was defined or an inspector. Now there are ways to do that, but it's not assumed. Some things move forward, others move back. paul
[toc] | [prev] | [next] | [standalone]
| From | Kaz Kylheku <847-115-0292@kylheku.com> |
|---|---|
| Date | 2019-05-29 17:09 +0000 |
| Message-ID | <20190529100309.66@kylheku.com> |
| In reply to | #32982 |
On 2019-05-28, Spiros Bousbouras <spibou@gmail.com> wrote: > On Tue, 28 May 2019 20:22:42 +0200 > "Pascal J. Bourguignon" <pjb@informatimago.com> wrote: >> Sai Sai <sairussuria@gmail.com> writes: >> >> > There should be a function that return the functions loaded from a file. >> >> No, there should not. It is useless. > > It's not useless , one might want to know for general information if nothing > else. It's not useless, but consider, in the light of how long Lisp has been around, that a beginner asked about such a feature in 2019. What might be useful is a utility that analyzes a file (either a compiled .fasl or a source file) without actually loading it, and produces a data structure that lists the symbols defined in that file (and perhaps ones that are not defined, but referenced) along with other info: what kind of thing they refer to and such. In the C-on-POSIX world, we can inspect object files with "nm", for instance. -- TXR Programming Lanuage: http://nongnu.org/txr Music DIY Mailing List: http://www.kylheku.com/diy ADA MP-1 Mailing List: http://www.kylheku.com/mp1
[toc] | [prev] | [next] | [standalone]
| From | "Pascal J. Bourguignon" <pjb@informatimago.com> |
|---|---|
| Date | 2019-05-29 20:40 +0200 |
| Message-ID | <m2v9xt14v7.fsf@despina.home> |
| In reply to | #32990 |
Kaz Kylheku <847-115-0292@kylheku.com> writes: > On 2019-05-28, Spiros Bousbouras <spibou@gmail.com> wrote: >> On Tue, 28 May 2019 20:22:42 +0200 >> "Pascal J. Bourguignon" <pjb@informatimago.com> wrote: >>> Sai Sai <sairussuria@gmail.com> writes: >>> >>> > There should be a function that return the functions loaded from a file. >>> >>> No, there should not. It is useless. >> >> It's not useless , one might want to know for general information if nothing >> else. > > It's not useless, but consider, in the light of how long Lisp has been > around, that a beginner asked about such a feature in 2019. > > What might be useful is a utility that analyzes a file (either a > compiled .fasl or a source file) without actually loading it, and > produces a data structure that lists the symbols defined in > that file (and perhaps ones that are not defined, but referenced) > along with other info: what kind of thing they refer to and such. > > In the C-on-POSIX world, we can inspect object files with "nm", for > instance. I wrote it useless, because: 1- it's incomplete, because of the nature of lisp. I would guesstimate that at least half the functions used in a lisp program come from a definite source file location; an explicit defun or defmethod form. Also notice already that defmethod doesn't define functions so the request itself is ill-defined, and you will have a lot of work to define it correctly. Toplevel form wouldn't cut it, you would want to find the source of anonymous functions too, why not. A lot of operators are defined with macros that define several of them (defstruct, defclass), and even worse, for application defined macros. But also, a number of functions won't even be defined at compilation-time, but rather at load-time or at run-time. 2- it just doesn't work. Basically, 75% of the time, when I M-. on an operator, it jump to a source file where there's a toplevel macro calling a function that uses macros to generate code, and I would still have to know the structure of the project, the files and the macros used to define it. 3- it should not be needed. More precisely here is a criticism of the file system as persistent storage for code. Consider a system similar to the Smalltalk browser (something like it could be implemented in emacs for code (lisp, C, etc)), where you would give a command to create a new (toplevel) object (package, type, variable, function, method, etc). A window would open to let you edit it, and when you save the window, emacs (the IDE) itself would decide where to store it (in a database, in a file system, in which file, etc). You would and should not have to think about where to store your forms in files. For all you know, the system could just store the forms in a database or in a lisp image. Implementing such a user interface could be a first step in being actually able to free us from the hierarchical file system. (The other step would be to implement GIT in a lisp image, to be able to use it without going thru the file system, there's already some cl-git system IIRC). 4- it's useless as a standalone tool, for the above reasons, but also, because implementations and tools already implement what they can about it to provide the M-. or (v in sldb) feature to jump to the source code, when it's possible (which is not often). Notably, some documentation tools try to locate source forms, but they can only do it very partially. I wouldn't count on them. You need to read the source, and to inspect a lisp image, to learn about it and know (and document) what is implemented. Or try to implement hacks like the code I provided, which answers literally to the question, and beyond, but again, which won't be used much more after having being written and tested, hence the "useless" qualifier. -- __Pascal J. Bourguignon__ http://www.informatimago.com
[toc] | [prev] | [next] | [standalone]
| From | Madhu <enometh@meer.net> |
|---|---|
| Date | 2019-05-29 06:43 +0530 |
| Message-ID | <m3v9xucbb5.fsf@leonis4.robolove.meer.net> |
| In reply to | #32978 |
* "Pascal J. Bourguignon" <m2muj630ct.fsf@despina.home> : Wrote on Tue, 28 May 2019 20:22:42 +0200: > Then don't quit clisp! Seriously! Never quit emacs or lisp, wait for > linux to crash Sadly this doesn't take much these days. Even if the kernel is stable the software environment has been made "crash-and-connect-to-mother-ship-on-restart-to-update" friendly. Especially if you are on a "modern linux" i.e. based on freedesktop dbus and elogind-protocols and "modern emacs" (compiled with the gtk toolkit)
[toc] | [prev] | [next] | [standalone]
| From | rpw3@rpw3.org (Rob Warnock) |
|---|---|
| Date | 2019-05-31 15:50 +0000 |
| Message-ID | <qcrifg$pge$1@dont-email.me> |
| In reply to | #32978 |
Pascal J. Bourguignon <pjb@informatimago.com> wrote: +--------------- | Sai Sai <sairussuria@gmail.com> writes: | > Obviously when I quit CLISP all my functions loaded from a file will be lost. | | Then don't quit clisp! Seriously! Never quit emacs or lisp, wait for | linux to crash, or to have to reboot for upgrades. | | Seriously. For example, I have an emacs with this uptime: | Up 73d 7h 27m 47s (Sat 2019-03-16 11:53:37), 14 buffers, 0 files +--------------- Not at all unusual. A CMUCL process on this system [middleware between Apache & PostgreSQL] has an uptime of 144 days 13+ hours [the uptime of the system since last reboot]. -Rob ----- Rob Warnock <rpw3@rpw3.org> 627 26th Avenue <http://rpw3.org/> San Mateo, CA 94403
[toc] | [prev] | [next] | [standalone]
| From | paul wallich <pw@panix.com> |
|---|---|
| Date | 2019-05-28 14:28 -0400 |
| Message-ID | <qcjujt$ar7$1@reader2.panix.com> |
| In reply to | #32976 |
On 5/28/19 2:12 PM, Sai Sai wrote: > But wait a minute... supose that I (defun fact... << factorial>>) in a file "test.lisp" then (load 'test.lisp) the function fact is in some place, because i write (fact 5) any time's and the interpreter returns =>120. > There should be a function that return the functions loaded from a file. As people have been trying to point out to you, it all depends on what you mean by new function. Let's say you load that file containing a definition of factorial, but you already had some other function called factorial that you'd defined in another file that you loaded. New function or just new version of old function? Ditto if you rewrite the factorial function at the repl. If you write a new function at the repl, do you want to count that, or just when loaded from files? If you just want to count/track new functions that you've written, you could write a MyDefun macro that pushes the name onto a list of functions and then executes the regular defun, but that wouldn't count anything in files you load that aren't written with that convention in mind. The underlying question is what you want to accomplish with this. > Obviously when I quit CLISP all my functions loaded from a file will be lost. (Unless you save an image that contains the new version of your programming universe, which is possible in Clisp and other lisps.) paul
[toc] | [prev] | [next] | [standalone]
| From | Sai Sai <sairussuria@gmail.com> |
|---|---|
| Date | 2019-05-28 11:53 -0700 |
| Message-ID | <00e7ae22-e06a-40bf-942e-c712a00db756@googlegroups.com> |
| In reply to | #32979 |
Thanks Paul, I try to learn lisp, well when I said <<factorial>> it take it like example. What I will like to do is when you load a file with a number of functions defined in it MyFun1 MyFun2 MyFun3 ... MyFunN a way to know the names that were loaded supose (nkd) => MyFun1 MyFun2 MyFun3 ... MyFunN. And in the case that some functions collide with existing function name should be an alert YOU WILL REDEFINE THE FUNTION <<ÑALSDJFAL>> !!! ARE YOU SHURE? I repeat Im learning and dont know if some of what I try to do, exist or not, and I havent yet the know to program it Thanks a lot to your atention
[toc] | [prev] | [next] | [standalone]
| From | Spiros Bousbouras <spibou@gmail.com> |
|---|---|
| Date | 2019-05-28 19:07 +0000 |
| Message-ID | <mn7PaSHiCHjuz4pOQW6J1fws@bongo-ra.co> |
| In reply to | #32976 |
On Tue, 28 May 2019 11:12:23 -0700 (PDT) Sai Sai <sairussuria@gmail.com> wrote: > But wait a minute... supose that I (defun fact... << factorial>>) in a file > "test.lisp" then (load 'test.lisp) the function fact is in some place, > because i write (fact 5) any time's and the interpreter returns =>120. The implementation will store the name fact and the code corresponding to fact but it won't necessarily store where or how fact was defined ; as in the file "test.lisp" in your example. > There should be a function that return the functions loaded from a file. It would be useful but the CL specification does not require it.
[toc] | [prev] | [next] | [standalone]
| From | taruss@google.com |
|---|---|
| Date | 2019-05-28 15:10 -0700 |
| Message-ID | <5578e19c-a7a7-4502-b0a8-e15ab1495a2c@googlegroups.com> |
| In reply to | #32976 |
On Tuesday, May 28, 2019 at 11:12:29 AM UTC-7, Sai Sai wrote:
> But wait a minute... supose that I (defun fact... << factorial>>) in a file "test.lisp" then (load 'test.lisp) the function fact is in some place, because i write (fact 5) any time's and the interpreter returns =>120.
> There should be a function that return the functions loaded from a file.
>
> Obviously when I quit CLISP all my functions loaded from a file will be lost.
Once you load the file, the function is present in the symbol table for lisp
with an appropriate function in the SYMBOL-FUNCTION slot. That is really all
that is required of the lisp implementation, since that is really all that is
needed for the interpreter/compiler to be able to use the information.
So, there does not need to be any function that returns the functions loaded
from a file. They can come from anywhere, including as Spiros noted, by just
typing in the information from the Read-Eval-Print-Loop.
There are some potential approximations to what you want, but unless you use
your own function definition macro which records additional information, you
won't be able to recreate this, necessarily. Or you could write a specialized
LOAD-WITH-ORIGIN that records the information using some of the example code that Pascal posted.
Some implementations may include additional information, but it wouldn't be a
portable solution. It does look like CLISP records where a function was
defined. For example something like:
(documentation 'my-function 'system::file)
=>
((SYSTEM::DEFUN/DEFMACRO #P"/my/home/directory/test.lisp" 2 3))
I have no idea what the numbers mean, though. It of course is going from the
symbol to the file and not the other way around. You would need to write a
function that would go through all symbols and find the matches you want.
Here is an example that works for me in CLISP 2.49.92:
(defun get-functions-defined-in-filename (filename)
(let ((function-symbols nil))
(setq filename (namestring filename)) ; Ensure the input type is string.
(do-all-symbols (symbol)
(when (fboundp symbol)
(let ((filedata (assoc 'system::defun/defmacro
(documentation symbol 'system::file))))
;; Use namestring because CLISP does not have an equality predicate
;; that works on pathname objects!
(when (equalp filename (namestring (second filedata)))
(push symbol function-symbols)))))
function-symbols))
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.lisp
csiph-web