Coder Social home page Coder Social logo

ape's People

Contributors

harrego avatar

Watchers

 avatar  avatar

Forkers

megabytesofrem

ape's Issues

Proposed syntax for ape 2.5

I propose to add the following syntax to ape to support list datatypes. As you can see, it is very simple and easy to use and leaves all the control up to the user of how they want to implement it.

/* %% DEFINEIFNOT DEFINED "ape_list.apeh" SUBMODULE */
ls_create()
  var param:size = "".unsafe_to_integer_defaulting_to("0".unsafe_to_integer());
  var list = "".unsafe_create_mutable();
  APE_BUILTIN_STRING_UTF16  
{
    /* create a mutable string to store our list */
    unsafe_mutable_append($list.unsafe_get_pointer(), ""+$param+size.unsafe_to_integer());
    return $list.to_unsafe().get_managed_vm().get_pointer().as_utf_16().unwrap_unsafe_global().to_returnable();
}

ls_addnode()
  var node
  var list
  void
{
  unsafe_mutable_get_container_type($list, $list.get_pointer().safe_to_unsafe_global().to_ref());
  unsafe_mutable_append($list.unsafe_get_pointer(), ""+$node+$node.get_managed_vm().get_pointer().as_utf_16().first()>>size.unsafe_to_integer());
}
/* %% ENDDEFINE */

/* %% APE_INCLUDE_SUBMODULE "ape_list.apeh" */
var ls = "";
var rs = APE_CREATE_RESULT_TYPE("Ok|Err[APE_BUILTIN_STRING_UTF16:e:DEFAULT:\"\"]".__APE_TO_STRUCT().unwrap_unsafe_char_array());

/* run some code in the interpretor state to store the result of the operation since ape doesnt have structs */
APE_CONTEXT_INTERP_RUN(rs, "rs.emit(=ret, [ctx], [=rs:])");
ls_create($ls.unsafe_get_pointer().to_ref());
if (ls!=""){ /* ls will be memory dump from raw RAM memory */
  ls_append($ls.unsafe_get_pointer().to_ref().try($rs);
  if (rs_Err) {
    print("ERR: "+rs_Err_getParameter_APE_BUILTIN_STRING_UT16__symbol_table_get_e+"");
  }
}
APE_MM_FREEPTR($ls.unsafe_get_pointer());
APE_CONTEXT_INTERP_CLOSE();```

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.