Skip to content

Allow for heterogeneous lists #29

Description

@qiemem

Currently, attempting to report a heterogeneous list gives a ParseException pyNetLogo attempts to the elements of a LogoList based on the type first element:

> netlogo.report('["hi" 8]')

java.text.ParseException: Java error in converting result: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
	at NetLogoLinkV61.NLResult.cast_logolist(NLResult.java:179)
	at NetLogoLinkV61.NLResult.logoToType(NLResult.java:69)
	at NetLogoLinkV61.NLResult.setResultValue(NLResult.java:15)
	at NetLogoLinkV61.NetLogoLink.report(NetLogoLink.java:198)

Heterogeneous lists are quite useful, especially when associating results with parameters.

It should be possible to return heterogeneous lists by leaving the LogoList elements boxed and converting to an object array (instead of a value array), or surfacing the LogoList to jpype directly and converting on the Python side (though I don't know much about jpype). These options could have a performance hit depending on how jpype's memory sharing works, but they could be done as fallback options when returning a value array would fail.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions