Skip to content

WIP: Add prolog implementation#187

Closed
ljos wants to merge 9 commits into
kanaka:masterfrom
ljos:master
Closed

WIP: Add prolog implementation#187
ljos wants to merge 9 commits into
kanaka:masterfrom
ljos:master

Conversation

@ljos

@ljos ljos commented Mar 22, 2016

Copy link
Copy Markdown

This is a work-in-progress prolog implementation.

Prolog, because of the shift in paradigm, needs to be implemented a little different than the rest of the languages. This is an attempt to do that.

@kanaka

kanaka commented Mar 22, 2016

Copy link
Copy Markdown
Owner

@ljos

I've been following your prolog implementation. The main thing that I like to see (related to merging into the main tree) is that every implementation follows the overall structure and incremental process. Your implementation doesn't seem too far off (similar in many ways to the Haskell implementation actually). I think the main thing I notice is that the core functions should be in a separate module if possible rather than defined inline in the step (step4).

You would probably find the mal FAQ informative if you haven't already seen it: https://github.com/kanaka/mal/blob/master/docs/FAQ.md#why-is-some-code-split-into-steps-and-some-code-not

Also, if you use IRC, I'm often available at #mal on freenode during the day (US central time).

@ljos

ljos commented Mar 22, 2016

Copy link
Copy Markdown
Author

Hi,

the main thing I notice is that the core functions should be in a separate module if possible rather than defined inline in the step (step4).

I've been meaning to do that. I haven't done it because I am not sure if it will stay the way it is. There is something that feels off to me. I will probably rebase a couple more times before it will be ready. You can see in eval vs. env that in eval I used a hash-map instead of the built-in database. I think the database is better, but I feel like there should be a way of doing it.

The ugliest thing right now is how I treat print_readable. That is decidedly un-prologesque. I need to find a better way of doing that. I think it should be possible to make the DCGs carry a value with them when unparsing, but I am not sure how to do that. I will have to do some research...

Thanks for the comments. It will probably take some time for me to finish this as prolog requires me to think differently when I solve problems then when I use a other programming languages, so it goes a bit slow. I just thought others might add some ideas or find it fun to look at, even though it is not finished.

@ljos
ljos force-pushed the master branch 4 times, most recently from 8482f6b to f95d821 Compare March 23, 2016 14:49
@ljos

ljos commented Jun 1, 2016

Copy link
Copy Markdown
Author

I'm sorry this is taking some time. Still a while until I can work on this again.

@ljos

ljos commented Aug 13, 2018

Copy link
Copy Markdown
Author

I realised some things about definite clause grammars and prolog (after 2 years) and now the implementation is a bit nicer to work with. I am little bit stuck on macros right now, but I should be able to solve it. There are some ugly things still (see swap! and still print_readably), but it is getting there.

@kanaka kanaka added the new_implementation A ticket that is proposing or requesting an implementation for a new language/platform label Jan 28, 2019
@kanaka

kanaka commented Mar 15, 2019

Copy link
Copy Markdown
Owner

@ljos Are you still interested in pushing this through to completion? If you aren't, or it may be a while please let me know and I'll close the issue until you are able to make progress. Thanks!

@ljos

ljos commented Mar 15, 2019 via email

Copy link
Copy Markdown
Author

ljos added 9 commits March 17, 2019 17:05
There probably are optimizations that can be done, but this is the
exact same code as in step4. We just rely on prologs builtin
tco. There is probably some magic we can do to implement it ourselves,
but I don't think that is neccessary.
@ljos

ljos commented Mar 17, 2019

Copy link
Copy Markdown
Author

It will take a bit longer than anticipated. I will close it and reopen when I have finished.

@ljos ljos closed this Mar 17, 2019
@kanaka

kanaka commented Mar 18, 2019

Copy link
Copy Markdown
Owner

@ljos Okay, no problem. I'm happy to take a look again in the future. Also no time pressure, apart from the policy that the first submission for each implementation is the one that is included in the tree (unless the subsequent implementations are notably different in interesting ways).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new_implementation A ticket that is proposing or requesting an implementation for a new language/platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants