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

ToString representation of some basic types are not mentioned #1072

Closed
Nadeeshan96 opened this issue Mar 28, 2022 · 6 comments
Closed

ToString representation of some basic types are not mentioned #1072

Nadeeshan96 opened this issue Mar 28, 2022 · 6 comments
Assignees
Labels
spec/undefined Spec does not define some behavour
Milestone

Comments

@Nadeeshan96
Copy link
Contributor

Description:

In the spec in section https://ballerina.io/spec/lang/master/#ToString information about the ToString representation of some of the basic types are not mentioned. Following the section https://ballerina.io/spec/lang/master/#section_5.1.4, ToString representation of function, future, typedesc, handle, stream basic behavioural types are missing. If the information on tuple and record types are the same as array and map types respectively, that can be also mentioned, if necessary.

Suggested Labels:

Code sample that shows issue:

public function main() {
    string funcStr = func.toString();
}

isolated function func(boolean|float firstarg, string secondarg="default", int... thirdarg) returns string {
    return "val";
}

Related Issues:

#499

@jclark
Copy link
Collaborator

jclark commented Apr 8, 2022

The table should say list and mapping rather than array and map.

@jclark jclark added the spec/undefined Spec does not define some behavour label Apr 8, 2022
@jclark
Copy link
Collaborator

jclark commented Apr 8, 2022

toString used to say

- if `v` is any other behavioral type, then the identifier for the behavioral type
#   (`function`, `future`, `service` or `handle`)
#   followed by some implementation-dependent string

but that got lost in b59a88e

Is that what jBallerina currently does?

@jclark jclark self-assigned this Apr 8, 2022
@Nadeeshan96
Copy link
Contributor Author

Is that what jBallerina currently does?

For the function, future, typedesc, stream types - yes.
For handle type, it gives the java object.toString() value without having the prefix handle.

@HindujaB
Copy link

HindujaB commented Apr 12, 2022

In addition, the spec does not mention the string representation of a typedesc value.
As per the spec,

  • if v is any other behavioral type, then the identifier for the behavioral type
    (function, future, service or handle)
    followed by some implementation-dependent string

IINM, it is expected to be typedesc with some implementation-dependent string representing its describing type. In that case, do we need the spec to mention the ToString for types?
For example,

readonly & record {|int a;|} b = {a: 4};
io:println(typeof b);

Since the typedesc describes a singleton structured value, should it be the shape of value b or the ToString of the map value?
related issue ballerina-platform/ballerina-lang#35092

@jclark
Copy link
Collaborator

jclark commented Apr 13, 2022

it is expected to be typedesc with some implementation-dependent string representing its describing type

Yes.

In that case, do we need the spec to mention the ToString for types?

Hard to do in general, and will probably change in jBallerina when it implements semantic subtyping. So best just to leave as implementation-dependent for now.

@HindujaB
Copy link

it is expected to be typedesc with some implementation-dependent string representing its describing type

Yes.

In that case, do we need the spec to mention the ToString for types?

Hard to do in general, and will probably change in jBallerina when it implements semantic subtyping. So best just to leave as implementation-dependent for now.

Ack. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec/undefined Spec does not define some behavour
Projects
None yet
Development

No branches or pull requests

3 participants