GithubHelp home page GithubHelp logo

ape's People

Contributors

kgabis avatar m0nt3-q avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ape's Issues

Collision / compile error on Windows

I was trying to get this to run on both Windows and Linux, and in Visual Studio I was getting a compile error on the enum error_type where there was a collision on ERROR_TIMEOUT with something in Windows.h. Just to test I changed all copies of that to be ERROR_TIME_OUT and it ran compiled/ran perfectly after.

I've looked at a lot of C based scripting languages over the last few weeks and I really like how well put together this is and how easily it's called via an interop scenario with C.

Since you asked someone else I thought I'd share, for fun, I work on MUDs (multi user dimensions, text based D&D type games online, were very popular in the 90's, the one I play still has hundreds of players). One of the most popular code bases are "Diku Muds" which have spawned thousands of forks/games. Most DikuMuds or their decedents have a VERY bare bones scripting language called mud progs or mob progs to allow the NPCs to crudely interact with players (they have basic control flow and access to some in game features, but no variable storage, etc.). Some muds have swapped that out for Lua (which is a big task and one so big that most people who do it don't share it which is a shame.. Lua is great but it also requires an insane amount of glue code and a lot of diligent managing the interop / using the stack correctly).

I was considering trying to swap this in either side by side or in replacement of mob progs in one of the open source code bases (probably ROM 2.4 but it's the one I know the best and plays the most like I expect a mud to play out of the box: https://github.com/avinson/rom24-quickmud). If I can do it successfully, I'll let you know.

Should `object_make_string` check for NULL input string?

Currently, I get a crash at

ape/ape.c

Lines 10208 to 10209 in d4a0c5c

object_t object_make_string(gcmem_t *mem, const char *string) {
int len = (int)strlen(string);
because I sometimes may pass NULL to the string parameter, and strlen crashes on NULL input on Ubuntu 16.04, should this part of code maybe do a check

object_t object_make_string(gcmem_t *mem, const char *string) {
    if (string == NULL) {
        return object_make_null();
    }
    int len = (int)strlen(string);

to handle non-expected NULL gracefully without crashing? :)

Thanks! Ape is great, I'm having a blast with it!

Problem with recusive

In the Ape Playgound website, the recursion example runs fine, but when I change the recusion number to 29 (or above 29), It report errors, below is the image:
image

Prefixing builtins with std::

Hi,
I'm considering prefixing builtins with std:: prefix, so instead of len and array one would write std::len and std::array. Why? Because there's a lot of keywords used up by builtins so it's quite easy to get a name collision for popular names (len, array, values, etc.). At the same time I want to add using (similar to c++ using namespace) to make converting existing code easier. Alternatively I might prefix functions with context dependent prefix, for instance values would become map::values, sqrt becoming math::sqrt. Since it's quite intrusive I wanted to ask users for opinion.

Memory callback functions accept user argument

Hello,

It would be great if the API for memory handling functions allowed for a user supplied argument -- which is useful for allocators that are not global.

typedef void*        (*ape_malloc_fn)(size_t size, void* mallocArg);
typedef void         (*ape_free_fn)(void *ptr, void* freeArg);

void ape_set_memory_functions(void* mallocArg, ape_malloc_fn malloc_fn, void* freeArg, ape_free_fn free_fn);

// user land code:
struct Allocator {
...
}

struct Program {
    struct Allocator* alloc;
} * program;

void* myMalloc(size_t size, void* arg) {
   struct Allocator* allocator = (struct Allocator*) arg; // allows to specify an allocator without being a global
   ...
}

...
ape_set_memory_functions(program.alloc, &myAlloc, program.alloc, &myFree);

Why .bn and not .ape?

This language is called Ape and the language extension is .bn. What does .bn means? Could you just make it .ape so it will be make sense?

Memory handling

Hello,

I think there might be some bugs with concat_fn:

  // I think should be: res_buf[len + arg_str_len] = '\0'; otherwise you are hitting invalid memory
  res_buf[len + arg_str_len + 1] = '\0'; 

Also in object_make_string_no_copy, there is an attempt to use memory after free:

if ((len + 1) < OBJECT_STRING_BUF_SIZE) {
        memcpy(obj->string.value_buf, string, len + 1);
        ape_free(string);  // <--- free'ng the memory here
        obj->string.is_allocated = false;
} else {
        obj->string.value_allocated = string;
        obj->string.is_allocated = true;
}
obj->string.hash = object_hash_string(string);   <-- Using it here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.