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

println stops working for strings above a certain length #11

Closed
esp1 opened this issue Jul 5, 2017 · 1 comment
Closed

println stops working for strings above a certain length #11

esp1 opened this issue Jul 5, 2017 · 1 comment

Comments

@esp1
Copy link

esp1 commented Jul 5, 2017

I noticed some strange behavior for println. With a memory pool configured, printing strings above a certain length causes the program to stop functioning properly, I'm guessing because of some kind of memory overflow. It would be reasonable to expect bad behavior if the code/string in question were excessively long, but it does not require a very long string to cause this issue. For example, the program below exhibits this behavior when compiled and run on an Arduino Uno:

(configure-runtime!
  FERRET_MEMORY_POOL_SIZE 512)

(println "123456789012345678901234")

If the string provided to println is shortened by a few characters, or if the memory pool is not configured, the program will function normally.

@nakkaya
Copy link
Owner

nakkaya commented Jul 6, 2017

Currently, strings in Ferret are costly. They are implemented as a sequence of numbers in a container in order to keep them behave like Clojure strings, they are mostly there for debugging purposes. I am still planning on how to implement them properly and portably so they work across multiple architectures.

My plan is to implement string then add a to_string method to the base so things like str can be implemented. As long as you use the Ferret API to go from C,C++ string to Ferret strings and vice versa everything should work when I implement the new string representation.

Also as a note, on atmega328 when you use strings they are always kept in memory even when they are not used. If you need to print a lot of stuff to the user use the F macros. That way strings are kept in flash instead of heap.

@nakkaya nakkaya closed this as completed Jul 6, 2017
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

No branches or pull requests

2 participants