Code Monkey home page Code Monkey logo

Comments (1)

mikesimons avatar mikesimons commented on August 28, 2024

Here is a first (fairly arbitrary) stab aiming to keep it simple.

Horizontal types are ruby
Vertical types are golang

Array / map conversions will follow key / value type conversion rules for each element. (e.g. map[string]float would follow string conversion rules for keys and float conversion rules for values).

Structs, user types & enums are not covered due to potential complexity of mapping.

I'm not sure if float -> int should be allowed due to precision loss. Dynamic languages typically allow this though.

It's also quite strict and does not allow (for instance) Fixnum -> bool conversion.

TrueClass FalseClass NilClass String Fixnum Bignum Float Range Array Hash Symbol
Float invalid invalid ZeroType atof FloatValue FloatValue FloatValue invalid invalid invalid invalid
String "true" "false" ZeroType StringValue StringValue StringValue StringValue invalid invalid invalid StringValue
Array invalid invalid ZeroType invalid invalid invalid invalid per-elem per-elem invalid invalid
Map invalid invalid ZeroType invalid invalid invalid invalid invalid invalid per-elem invalid
Int invalid invalid ZeroType atoi IntValue IntValue ? invalid invalid per-elem invalid
Bool true false ZeroType invalid invalid invalid invalid invalid invalid invalid invalid

Due to the breadth of work implementing this will require I will await feedback before proceeding.

from go-mruby.

Related Issues (20)

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.