Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import an LOOP macro #1579

Merged
merged 7 commits into from Mar 17, 2024
Merged

import an LOOP macro #1579

merged 7 commits into from Mar 17, 2024

Conversation

masinter
Copy link
Member

No description provided.

@pamoroso
Copy link
Contributor

On Medley Online, when I load CML-LOOP.DFASL I get this break window with the error Can't find package for DEFINE-FILE-INFO reader environment XLP:

cml-loop-error

Not sure I'm loading it correctly.

@masinter
Copy link
Member Author

masinter commented Mar 14, 2024 via email

@pamoroso
Copy link
Contributor

This and the documentation it references might help setting up the package for use with the File Manager.

@masinter
Copy link
Member Author

I changed the file name to XCL-LOOP and added it to the loadup.
I fixed the package problems I hope.

@masinter masinter closed this Mar 14, 2024
@pamoroso
Copy link
Contributor

Now it seems to be working. Pretty cool.

xcl-loop

@masinter masinter requested a review from pamoroso March 14, 2024 22:01
@masinter masinter reopened this Mar 14, 2024
@nbriggs
Copy link
Contributor

nbriggs commented Mar 15, 2024

Why XCL- instead of CML?

Should loop be in its own package or should it be part of cl:/lisp: package if it's part of the language spec (or xcl: if it's "our own" implementation)

@MattHeffron
Copy link
Contributor

I concur with @nbriggs .
Why is this in the "XLP" package? Doesn't that mean that all of the symbols that the loop macro uses for its extended form would have to be imported into whatever package the code using it is read in? Or all used as xlp::symbol?
In fact, the loop macro itself is in the "XLP" package and it isn't even exported from that package. So, even to use the simplest loop form requires either:
(xlp::loop forms)
or to (import (find-symbol "loop" "xlp") "name of package of code using loop") before the code using the loop macro is read,
or to put a similar import as part of the DEFPACKAGE of the file environment of a file using the macro.

If it's part of the standard, then put it into the correct package.

Is the point not to redefine the existing loop macro as defined in CMLSPECIALFORMS? It looks like that implementation and syntax would be handled correctly by the new fuller loop macro.

@masinter
Copy link
Member Author

Interestingly the other words in the extended f op rm are pname only and can be in any or no (I interned at all. Only two symbols are exported: loop and loop-finish. That's why it works without the contortions @MattHeffron predicted. Try it!

Copy link
Contributor

@pamoroso pamoroso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest version seems to be working fine and no special handling of packages is required. Here's a quick test of evaluating at a XCL Exec a few loop expressions from Peter Seibel's book:

xcl-loop

Running an infinite loop with (loop) works too.

@pamoroso
Copy link
Contributor

A call to this implementation of loop to iterate over a hash table produces the error Undefined car of form XLP::WITH-HASH-TABLE-ITERATOR as reported in issue #609.

@nbriggs
Copy link
Contributor

nbriggs commented Mar 16, 2024

Both WITH-HASH-TABLE-ITERATOR and WITH-PACKAGE-ITERATOR definitions seem to be missing. (Latest version of the branch moves the package for the internal mechanism of the loop macro to LOOP: and sorts out the conflict with CMLSPECIALFORMS which already defined LOOP)

…rted from LISP. Install copyright/acknowledgement
@nbriggs
Copy link
Contributor

nbriggs commented Mar 16, 2024

The author of the loop.lisp has the hash table bits as well.

@masinter
Copy link
Member Author

I changed the package to "LOOP" and made sure "LOOP" and "LOOP-FINISH" were exported from the LISP package.

@masinter
Copy link
Member Author

i spent the better part of a day on Both WITH-HASH-TABLE-ITERATOR and WITH-PACKAGE-ITERATOR and have decided to put that on ice because I don't want to change Medley's implementation of hash-tables or packages.
Those two features aren't part of LOOP.
I did find a couple of differences/bug fixes with a newer loop.liap.

@masinter
Copy link
Member Author

I missed the parts about -TABLE-ITERATOR and WITH-PACKAGE-ITERATOR being used in some LOOP iterators.
But I don't want to hold this for them. I made a separate issue.

@masinter masinter merged commit 8e07e25 into master Mar 17, 2024
@masinter masinter deleted the loop-macro branch March 27, 2024 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants