<commit_before>###
# [close]

.HLL 'Tcl', 'tcl_group'
.namespace

.sub '&close'
    .param pmc argv :slurpy

    .local int argc
    argc = elements argv
    
    .return('')
.end
<commit_msg>[tcl]    * implement [close], check ticket #40706 for details<commit_after>###
# [close]

.HLL 'Tcl', 'tcl_group'
.namespace

.sub '&close'
    .param pmc argv :slurpy

    .local int argc
    argc = elements argv

    if argc != 1 goto bad_args
    
    .local string channel_id
    channel_id = argv[0]

    .local pmc channels, next_channel_id, io_obj
    channels = get_root_global ['_tcl'], 'channels'
    next_channel_id = get_root_global ['_tcl'], 'next_channel_id'

    io_obj = channels[channel_id]
    if null io_obj goto channelid_error

    io_obj.'flush'() # XXX refactor when we have events working
    close io_obj

    delete channels[channel_id]
    # XXX update channel ids (after "proper" way of handling ids is defined)

    .return('')

  channelid_error:
    $S0 = 'can not find channel name "'
    $S0 .= channel_id
    $S0 .= '"'
    tcl_error $S0

  bad_args:
    tcl_error 'wrong # args: should be "close channelId"'

.end

{'fraction_non_alphanumeric': 0.11481156879929887, 'fraction_numerical': 0.009640666082383873, 'mean_word_length': 2.924398625429553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4214755', 'n_tokens_mistral': 418, 'n_tokens_neox': 401, 'n_words': 121}