Skip to content

Ulsp - standardise table initialisation and standard Unicon function names - #668

Open
brucerennie wants to merge 13 commits into
uniconproject:masterfrom
brucerennie:ulsp
Open

brucerennie wants to merge 13 commits into
uniconproject:masterfrom
brucerennie:ulsp

Conversation

@brucerennie

@brucerennie brucerennie commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

The table initialisation has been standardised across all the files contained in the ulsp package,

changed the various uses of table(key, value, ...) to the format [key : value; ...]

updated all references to the standard unicon functions from func(...) to ::func(...)

This pull request is a cosmetic code update and is optional as to whether or not it is actually installed into the master branch of the unicon project. I found it was much easier to read the code for the ulsp package by doing this.

Any discussion for this pull request is welcome.

…e definition

Change the definition of a table structure using table(.....) to the form [key : value; ...] for consistency across all ulsp related files.

The second change is to change all calls to Unicon internal functions to use the :: prefix as in change put(...) to ::put(..).
See details in completion.icn
@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown

Greptile Summary

This PR standardizes ULSP table initialization with table literals and qualifies standard Unicon functions with the global namespace operator.

  • Most constructor conversions preserve their previous data structures.
  • One malformed namespace qualifier prevents compilation.
  • The LSIF hover-result conversion changes the serialized JSON from an object to an array.

Confidence Score: 3/5

The PR is not safe to merge until the ULSP compilation error and malformed LSIF hover-result structure are corrected.

The repeated namespace operator can prevent the package from compiling, while the comma-separated hover contents expression serializes an array instead of the required keyed result object.

Files Needing Attention: uni/ulsp/file_handler.icn, uni/ulsp/lsif.icn

Important Files Changed

Filename Overview
uni/ulsp/file_handler.icn Qualifies standard functions and converts tables, but introduces the malformed ::::many expression in object parsing.
uni/ulsp/lsif.icn Converts nested LSIF structures to literals, but changes the hover result from a keyed table to a list.
uni/ulsp/completion.icn Converts completion-item tables and qualifies built-ins without changing their key/value structures.
uni/ulsp/signature.icn Standardizes signature response tables and built-in calls while preserving response fields.
Prompt To Fix All With AI
### Issue 1
uni/ulsp/file_handler.icn:415
**Malformed namespace qualifier**

When `file_handler.icn` is compiled, the repeated namespace operator in `::::many` is invalid and prevents the ULSP package from building. The surrounding calls correctly use `::many`.

```suggestion
               ::tab(::many(' \t'))
```

### Issue 2
uni/ulsp/lsif.icn:299-300
**Hover result becomes array**

This conversion uses a comma after `"contents"`, producing a two-element list instead of a table with a `contents` key. `tojson` therefore emits an array where an LSIF hover-result object is required, so consumers cannot access `result.contents` and may reject the generated index.

```suggestion
         "result" : ["contents" : [["language" : "unicon"; 
                                     "value" : value]]]
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "Update symbols.icn - standardise functio..." | Re-trigger Greptile

Comment thread uni/ulsp/file_handler.icn Outdated
objectName := ::tab(::many(&digits ++ &letters ++ '-' ++ '_'))
::tab(::many(' \t'))
::move(2)
::tab(::::many(' \t'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Malformed namespace qualifier

When file_handler.icn is compiled, the repeated namespace operator in ::::many is invalid and prevents the ULSP package from building. The surrounding calls correctly use ::many.

Suggested change
::tab(::::many(' \t'))
::tab(::many(' \t'))
Prompt To Fix With AI
This is a comment left during a code review.
Path: uni/ulsp/file_handler.icn
Line: 415

Comment:
**Malformed namespace qualifier**

When `file_handler.icn` is compiled, the repeated namespace operator in `::::many` is invalid and prevents the ULSP package from building. The surrounding calls correctly use `::many`.

```suggestion
               ::tab(::many(' \t'))
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment thread uni/ulsp/lsif.icn Outdated
Comment on lines +299 to +300
"result" : ["contents", [["language" : "unicon";
"value" : value]]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Hover result becomes array

This conversion uses a comma after "contents", producing a two-element list instead of a table with a contents key. tojson therefore emits an array where an LSIF hover-result object is required, so consumers cannot access result.contents and may reject the generated index.

Suggested change
"result" : ["contents", [["language" : "unicon";
"value" : value]]]
"result" : ["contents" : [["language" : "unicon";
"value" : value]]]
Prompt To Fix With AI
This is a comment left during a code review.
Path: uni/ulsp/lsif.icn
Line: 299-300

Comment:
**Hover result becomes array**

This conversion uses a comma after `"contents"`, producing a two-element list instead of a table with a `contents` key. `tojson` therefore emits an array where an LSIF hover-result object is required, so consumers cannot access `result.contents` and may reject the generated index.

```suggestion
         "result" : ["contents" : [["language" : "unicon"; 
                                     "value" : value]]]
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@Don-Ward Don-Ward left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is not about changing functionality but instead (as is admitted) more about coding style. Thus its acceptance is more a matter of opinion than one of correctness -- unless it violates our coding standards, of which there are few.

Having said that, I don't find the editted text easier to read than the original version. I usually treat the :: as an explicit warning that the global identifier in question has been redefined locally and the :: makes it clear that the global definition is required, rather than the local one. When there is no redefinition the warning is not required and, to me, is just uneccessary noise. Obviously, Bruce doesn't agree with me.

If all, or even most, of the other unicon source were coded with :: and the PR was making this code conform with the rest, I'd be in favour of it. But that isn't the case; if anything the reverse is true.

The changes in table initialisation are probably a good thing (in my opinion) not because they are easier to read -- I find the two versions about the same -- but because it's harder to inadvertantly make a mistake by inserting a spurious comma.

@brucerennie

Copy link
Copy Markdown
Collaborator Author

@Don-Ward

Thank you for your feedback.

From my perspective, it is important that I understand what others perceive as being more readily comprehensible within the code base. So when you say [Having said that, I don't find the editted text easier to read than the original version.], this, in effect, clarifies for me what others might or might not find easier to read and comprehend.

In the particular case as you state [I usually treat the :: as an explicit warning that the global identifier in question has been redefined locally and the :: makes it clear that the global definition is required, rather than the local one.], I am in agreement with you. However, I like clarity as to where a reference is pointing to, the current package, an imported package or the global environment.

I have found in my own coding that certain problems have arisen when [importing] other packages. This has caught me out a couple times and as such, I tend now to directly reference the associated package for any class/procedure/method/record even with an import directive, including the global environment.

This particular problem may be very much limited to what I do and not at all apply to anyone else.

I do appreciate that this may be [just uneccessary noise] for those who are long time users of the language. Where I am coming from here is looking at the perspective of new Unicon users. I would very much like to see more people taking up the language as a standard tool.

If one goes through the IPL and the UNI sets of files, there is a large variety of expression construction. Some of it is quite idiomatic in terms of the basic ideas from icon and Unicon. But there is also plenty of code that is, how shall we put this, written in idiomatic BASIC or FORTRAN. Yes that is hyperbole, but I think you will get what I mean. Even withing the same file or procedure, an idiomatic form may be used in one place and a non-idiomatic form used nearby.

As you say Don, [If all, or even most, of the other Unicon source were coded with :: and the PR was making this code conform with the rest, I'd be in favour of it. But that isn't the case; if anything the reverse is true.] and one of my longer term projects is to attempt to update the entire code base to be more idiomatic and document the various forms that can be used. Again, this PR is more for discussion and feedback than being pushed to get these changes in.

As we have seen in the past, there are various members of the community that have quite strong feelings about coding style as well as other aspects applicable to Unicon and the available facilities. This is actually a very good thing as it allows all of us to consider alternatives to the specific ways we as individuals might write Unicon code.

As for the table initialisation, I personally find the new form much easier to read and comprehend. The table(...) call form is for me somewhat discordant and hides what is going on here.

So again, Don, thank you for your feedback. It is much appreciated.

@Jafaral

Jafaral commented Sep 18, 2026

Copy link
Copy Markdown
Member

I do like the table format change. I do agree that format is much more readable than using table(). I also agree with Don's opinion. put() looks much better than ::put(), especially with functions as basic as put().

@brucerennie

brucerennie commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

@Jafaral @Don-Ward @cjeffery How about I close this PR and create a new PR that only has the table() change? If there is agreement on that, I will make the changes this weekend. I wait to here from each of you.

Have a blessed weekend.

By the way there is a small error in one of the files when looking for source files with the .icn suffix. The code assumes that "." only occurs once in the file name and doesn't actually look for ".icn" as the suffix. I will create a PR for this next week.

@Don-Ward

Copy link
Copy Markdown
Collaborator

The proposal to just implement the table changes works for me. But, might it be worth waiting for the opinions of the other reviewers? It could be that Jafar and I are a vocal minority and the consensus goes the other way.

@brucerennie

Copy link
Copy Markdown
Collaborator Author

Until there is agreement one way or the other, I won't be generating the PR. I will however be looking at the other problem I found.

@Jafaral

Jafaral commented Sep 27, 2026

Copy link
Copy Markdown
Member

@brucerennie , In most cases, it is better to not close a PR to open a replacement unless a completely new approach is taken. In most cases, you can just make changes to the same PR, preferably by dropping/amending/adding commits and using force push to avoid code churn between commits.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants