New array features

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: New array features

Post by Lost Zergling »

@fxm : Thanks a lot. I now have a better idea of how I perhaps could proceed. I'll make some try using integer Ptr.
@speedfixer : about implementation. You're right. For years, I rather tried to guess how the underlying treatments were organized rather than looking at the solutions. A huge waste of time but also a way to try to understand in depth. A way of wanting to redo the wheel. In my defense, this led me to design a tool focused on transparency between the syntax of the instruction set and the implementation.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: New array features

Post by paul doe »

Tourist Trap wrote:...
Use namespace please also, for the same reason. But you probably noticed that defines/macro can not be isolated in namespaces - unless I missed something of course.
#defines respect namespaces, #macros don't (they're defined in the global namespace).
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: New array features

Post by paul doe »

Juergen Kuehlwein wrote:@paul doe,

as already mentioned above there is a bug in the interface, it works for one-dimensional arrays using the following syntax:
...
Fair enough. But I take it that you're well aware that the interface should be fully orthogonal (we already have a lot of 'quirk' statements inherited from the archaic BASIC dialect FreeBasic is based on).

In all honesty, I don't think that #macros are the way to go in this case. Indeed, they offer more flexibility than functions, but they also pollute the global namespace and add bloat to the code (especially since your #macros are non-trivial). Jeff also stated some of the reasons this is not the preferred method of adding new features to the compiler. The final choice, naturally, is yours.
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: New array features

Post by Lost Zergling »

@Juergen Kuehlwein "I´m still looking for a way to have a consistent and flexible syntax using keywords and optional parameters as well. "
If I had to design an instruction set for arrays in conjunction with my programming style, it should meet the following criteria: ease, flexibility, and open door to creativity. Once one has said that, the question of how is asked. The combination of the criteria of ease, flexibility and power will impose sacrifices on performance.
To answer the question, here is how I would do the design, but it would be a first draft:
The main difference is to give the user the hand on the underlying linear iterator so as not to confine it to the parsing of the data by having to specify the indices for each element.
Then, instead of using dedicated fast functions or calls in c I will use my semi-automatic indexer for both functions (over-implementation) but also as a possibility for the user to use it directly to his liking thanks to the parser.
This would deeply impact the logic of the instruction set:
Aext_Lcursor (element): specify a starting element in an array for being used by functions.
Aext_Rcursor (element): specify a ending element
Aext_SetCursor (item): set starting point for parsing
Aext_Step (array): jump to next element (must NOT be Aext_Step (element))
Aext_StepCursor (integer): a number of elements to jump when parsing (for example, by specifying the number of elements on a line, we parse on the column) (we can parse a dimension)
Then more "classic" functions:
Aext_Sort, Aext_Search, Aext_Unique but automatically taking into account Lcursor, Rcursor and StepCursor as they are settled when the function is called.
Finally, an interesting function could be the persistence of the transposition vector of the last sorting performed: when sorting on a line, the index memorizes for each element the position of the original column. It would then be sufficient for the user to specify a vector (eg beginning and end of the second line), and then:
Aext_Apply (array): repercutes the consequences of sorting the first line on the second line. It would be possible to propagate the consequences of a sort on a vector or array to another.
As I said, this just a first idea, the way I would conceive it.
Forgot (at least one) Aext_Value : return current element value otherwise returned by Aext_Step.
=> I'd call this one an instruction set.
Juergen Kuehlwein
Posts: 284
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Post by Juergen Kuehlwein »

I would like to have an intuitive yet flexible syntax for the new array features. After testing this and trying that i think i found an approach, which is intuitive, flexible and doesn´t "pollute" the global namespace in an unacceptable way.

The following code should demonstrate the principle of how it works. I need two new key words in global namespace: "array" (generic macro) and "array_" (namespace). All other names used in the context of the array features are isolated by the namespace and/or a scope block. So there should be no naming conflicts elsewhere.

Code: Select all

'#COMPILER FREEBASIC 
'#compile console 32 

'***********************************************************************************************
'***********************************************************************************************


namespace array_


enum array_enums_ explicit                            'keywords for array features
  sort    = 1                                         'sort array
    up 
    down

  insert  = 10                                        'insert element 

  exclude = 20                                        'delete element (better keyword ?)

  scan    = 30                                        'scan array (perform a search)

  info    = 40                                        'get descriptor information 
   data                                               'pointer to the first array element in memory
   dimensions                                         '# of dimensions (same as UBOUND(array, 0)
   totalsize                                          'in bytes 
   totalcount                                         'total # of elements in all dimensions
   size                                               'same as sizeof(array)

' ...
end enum


private Function array_get_ptr_(Byval p As Any Ptr) As Any Ptr
  Return p                                            'return passed array descriptor ptr
End Function


private function sort_array_ (byval t as integer, byval ap as any ptr, byval cp as any ptr, byval p2 as integer, _
                              byval start as integer = 0, byval count as integer = 0, byval sa as any ptr = 0) _
                              as long
'***********************************************************************************************
' array sort function (just demonstrate, that parameter passing works)
'***********************************************************************************************


  print "var type:              " + str(t)
  print "array ptr:             " + hex(ap)
  
  if cp = 2 then
    print "direction:             up"
  elseif cp = 3 then      
    print "direction:             down"
  else  
    print "custom proc:           " + hex(cp)
  end if

  print
  if p2 = 1 then
    print "additional parameters: yes"
  else
    print "additional parameters: no"
  end if

  print "start index:           " + str(start)
  print "index count:           " + str(count)

  if sa = 0 then
    print "sort along array:      no"
  else
    print "sort along array:      " + hex(sa)
  end if


  function = 0
  

end function


'***********************************************************************************************
' more functions ...
'***********************************************************************************************


end namespace


#macro array(v, a, p1, p2...)                         'generic array processing macro
scope


#define sort_along(a) Cptr(any ptr, Cptr(uinteger Ptr, Cast(Function(() As Typeof(a)) As any Ptr, @array_.array_get_ptr_)(a())))


#if TypeOf((a))     = BYTE
  #define a_d_t_ 1                                    'array´s data type
#elseif TypeOf((a)) = UBYTE
  #define a_d_t_ 2
#elseif TypeOf((a)) = SHORT
  #define a_d_t_ 3
#elseif TypeOf((a)) = USHORT
  #define a_d_t_ 4
#elseif TypeOf((a)) = INTEGER
  #define a_d_t_ 5
#elseif TypeOf((a)) = UINTEGER
  #define a_d_t_ 6
#elseif TypeOf((a)) = LONG
  #define a_d_t_ 7
#elseif TypeOf((a)) = ULONG
  #define a_d_t_ 8
#elseif TypeOf((a)) = LONGINT
  #define a_d_t_ 9
#elseif TypeOf((a)) = ULONGINT
  #define a_d_t_ 10

#elseif TypeOf((a)) = SINGLE
  #define a_d_t_ 20
#elseif TypeOf((a)) = DOUBLE
  #define a_d_t_ 21

#elseif typeof((a)) = typeof(zstring * sizeof(typeof((a))))
  #define a_d_t_ 30
#elseif TypeOf((a)) = STRING
  #define a_d_t_ 31
#elseif typeof((a)) = typeof(Wstring * sizeof(typeof((a))))
  #define a_d_t_ 32
#elseif TypeOf((a)) = Typeof(USTRING)
  #define a_d_t_ 33
#elseif TypeOf((a)) = TypeOf(CWSTR)
  #define a_d_t_ 34
#elseif TypeOf((a)) = TypeOf(CBSTR)
  #define a_d_t_ 35
#else
  #define a_d_t_ 40
#endif


#if (array_.array_enums_.##v = 1)                     'sort
  #if ((#p1 = "UP") or (#p1 = "DOWN"))
    #if a_d_t_ = 40
      #error "Array Sort: Only standard variable types are supported, consider using a custom sort function"
    #else
      #if (#p2 <> "")
        array_.sort_array_(a_d_t_, sort_along(a), cast(any ptr, array_.array_enums_.##p1), 1, p2)
      #else
        array_.sort_array_(a_d_t_, sort_along(a), cast(any ptr, array_.array_enums_.##p1), 0)
      #endif 
    #endif 
  #else
    #if (#p2 <> "")
      array_.sort_array_(a_d_t_, sort_along(a), p1, 1, p2)
    #else
      array_.sort_array_(a_d_t_, sort_along(a), p1, 0)
    #endif 
  #endif


#elseif (array_.array_enums_.##v = 10)                'insert
#elseif (array_.array_enums_.##v = 20)                'exclude
#elseif (array_.array_enums_.##v = 30)                'scan
#elseif (array_.array_enums_.##v = 40)                'info

' ...

#endif 


end scope
#endmacro


function custom_sort_proc () as long
'***********************************************************************************************
' testing ...
'***********************************************************************************************

  return 0
  

end function


'***********************************************************************************************


'const sort = 1                                        'this works
'#define sort 1                                        'this doesn´t


' i can have CONSTs, ENUMs, procedures and variables with the keywords name´s 
' but obviously i cannot not have #DEFINEs for these words !


dim a(1 to 5) as long
dim b(1 to 5) as byte


array(sort, a, up, 1, 5, sort_along(b))
array(sort, a, up, 1, 5)
array(sort, a, up, 1)
array(sort, a, up)
array(sort, a, down, 1, 5, sort_along(b))
array(sort, a, @custom_sort_proc, 1, 5, sort_along(b))



sleep
end


' global are "array" and "array_", all others are useable except for #DEFINES



For sorting the syntax is as follows:

array(action verb, array-name, specifier (up/down/@customsort) [, starting index, [# of elements to sort, [array to sort in the same order]]]

- we must have at least three parameters: action verb (sort, insert, ...), array name, specifier (what to do)
- but we can have more, if necessary
- the macro wraps a function specific for the action to take, this function could in turn call a RTL function or even be a RTL function
- even if the macro is not trivial, some parsing is done at compile time, so the expanded code is quite trivial

What do you think? If we want to avoid option 3 (Jeff did´t recommend it anyway), would that basically meet the needs we have been discussing? Comments, critics, bug reports, better names and ideas for possible improvements are welcome!


JK
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: New array features

Post by fxm »

Code: Select all

#define sort_along(a) Cptr(any ptr, Cptr(uinteger Ptr, Cast(Function(() As Typeof(a)) As any Ptr, @array_.array_get_ptr_)(a())))
See #889 Complex/compact syntax unsupported by gcc (except with compile option -exx)
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: New array features

Post by Lost Zergling »

I will not rate an appreciation on the technical side. I think it is fine if we can have different functionality and logics because they will be complementary. A set of basic instructions provides a methodology while a function allows the execution speed and a dense coding. I do not know when or if I could "have fun" trying to code some ideas and thoughts that we could have in this thread, but I think thoughts sharing was very positive. We now have a better transparency on different visions and approach which will enrich the language.
Juergen Kuehlwein
Posts: 284
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Post by Juergen Kuehlwein »

Ok, next try...

Code: Select all

'#COMPILER FREEBASIC 
'#compile console 64 

'***********************************************************************************************
'***********************************************************************************************


namespace array_


enum array_enums_ explicit                            'keywords for array features
  sort    = 1                                         'sort array
    up 
    down
  sort2

  ins     = 10                                        'insert element 

  del     = 20                                        'delete element 

  scan    = 30                                        'scan array (perform a search)

  info    = 40                                        'get descriptor information 
   data                                               'pointer to the first array element in memory
   dimensions                                         '# of dimensions (same as UBOUND(array, 0)
   totalsize                                          'in bytes 
   totalcount                                         'total # of elements in all dimensions
   size                                               'same as sizeof(array)

  calc    = 50                                        'calculate an elements linear # from indices (multiple dimensions)
  
  at      = 60                                        'dim an overlay array at a memory location (don´t initialize) 
  reset                                               'erase it again, but leave the underlying memory untouched
  
' ...
end enum


private Function array_get_ptr_(Byval p As Any Ptr) As Any Ptr
  Return p                                            'return passed array descriptor ptr
End Function


private function sort_array_ (byval t as integer, byval ap as any ptr, byval sa as any ptr, byval cp as any ptr, _
                              byval p2 as integer, byval start as integer = 0, byval count as integer = 0) _
                              as long
'***********************************************************************************************
' array sort function (just demonstrate parameter passing works)
'***********************************************************************************************

  print
  print "parameters"
  print "var type:              " + str(t)
  print "array ptr:             " + hex(ap)
  
  if cp = 2 then
    print "direction:             up"
  elseif cp = 3 then      
    print "direction:             down"
  else  
    print "custom proc:           " + hex(cp)
  end if

  if sa = 0 then
    print "sort along array:      no"
  else
    print "sort along array:      " + hex(sa)
  end if

  print
  if p2 = 1 then
    print "additional parameters: yes"
  else
    print "additional parameters: no"
  end if

  print "start index:           " + str(start)
  print "index count:           " + str(count)


  function = 0
  

end function


'***********************************************************************************************
' more functions ...
'***********************************************************************************************


end namespace


#macro array_get_data_type__ (a)
  #if TypeOf((a))     = BYTE
    #define a_d_t_ 1                                    'array´s data type
  #elseif TypeOf((a)) = UBYTE
    #define a_d_t_ 2
  #elseif TypeOf((a)) = SHORT
    #define a_d_t_ 3
  #elseif TypeOf((a)) = USHORT
    #define a_d_t_ 4
  #elseif TypeOf((a)) = INTEGER
    #define a_d_t_ 5
  #elseif TypeOf((a)) = UINTEGER
    #define a_d_t_ 6
  #elseif TypeOf((a)) = LONG
    #define a_d_t_ 7
  #elseif TypeOf((a)) = ULONG
    #define a_d_t_ 8
  #elseif TypeOf((a)) = LONGINT
    #define a_d_t_ 9
  #elseif TypeOf((a)) = ULONGINT
    #define a_d_t_ 10

  #elseif TypeOf((a)) = SINGLE
    #define a_d_t_ 20
  #elseif TypeOf((a)) = DOUBLE
    #define a_d_t_ 21

  #elseif typeof((a)) = typeof(zstring * sizeof(typeof((a))))
    #define a_d_t_ 30
  #elseif TypeOf((a)) = STRING
    #define a_d_t_ 31
  #elseif typeof((a)) = typeof(Wstring * sizeof(typeof((a))))
    #define a_d_t_ 32
  #elseif TypeOf((a)) = Typeof(USTRING)
    #define a_d_t_ 33
  #elseif TypeOf((a)) = TypeOf(CWSTR)
    #define a_d_t_ 34
  #elseif TypeOf((a)) = TypeOf(CBSTR)
    #define a_d_t_ 35
  #else
    #define a_d_t_ 40
  #endif
#endmacro


#macro array_sort_along_with__(x, y)
  dim p as any ptr
  Dim As Function (() As Typeof((x))) As Any Ptr f
  f = Cast(Function (() As Typeof((x))) As Any Ptr, @array_.array_get_ptr_)
  p = f(x())

  dim p3 as any ptr
  Dim As Function (() As Typeof((y))) As Any Ptr f3
    f3 = Cast(Function (() As Typeof((y))) As Any Ptr, @array_.array_get_ptr_)
    p3 = f3(y())

  array_get_data_type__ (x)
#endmacro


#macro array(v, a, p1, p2...)                         'generic array processing macro
scope

#if (#a < ")")                                        'starts with "(" -> two arrays to sort along
  array_sort_along_with__ a
#else
  dim p  as any ptr
  dim p3 as any ptr = 0
  Dim As Function (() As Typeof((a))) As Any Ptr f
  f = Cast(Function (() As Typeof((a))) As Any Ptr, @array_.array_get_ptr_)
  p = f(a())

  array_get_data_type__ (a)
#endif


#if (array_.array_enums_.##v = array_.array_enums_.sort)                  'sort
  #if ((#p1 = "UP") or (#p1 = "DOWN"))
    #if a_d_t_ = 40
      #error "Array Sort: Only standard variable types are supported, consider using a custom sort function"
    #else
      #if (#p2 <> "")
        array_.sort_array_(a_d_t_, p, p3, cast(any ptr, array_.array_enums_.##p1), 1, p2)
      #else
        array_.sort_array_(a_d_t_, p, p3, cast(any ptr, array_.array_enums_.##p1), 0)
      #endif 
    #endif 
  #else
    #if (#p2 <> "")
      array_.sort_array_(a_d_t_, p, p3, p1, 1, p2)
    #else
      array_.sort_array_(a_d_t_, p, p3, p1, 0)
    #endif 
  #endif



#elseif (array_.array_enums_.##v = 2)                 'insert
#elseif (array_.array_enums_.##v = 3)                 'delete
#elseif (array_.array_enums_.##v = 4)                 'scan
#elseif (array_.array_enums_.##v = 5)                 'info

'...

#endif 

end scope
#endmacro


function custom_sort_proc () as long
'***********************************************************************************************
' testing ...
'***********************************************************************************************

  return 0
  

end function


'***********************************************************************************************


'const sort = 1                                        'this works
'#define sort 1                                        'this doesn´t


' i can have CONSTs, ENUMs, procedures and variables with the keywords name´s 
' but obviously i cannot not have #DEFINEs for these words !


dim a(1 to 5) as long
dim b(1 to 5) as byte


array(sort, a, up, 1, 5)
array(sort, a, up, 1)
array(sort, a, up)
array(sort, (a, b), down, 1, 5)
array(sort, a, @custom_sort_proc, 1, 5)


sleep
end

The the syntax is now as follows:

array(action verb, array-name/(array-name, array-name to sort in the same order), specifier (up/down/@customsort) [, starting index, [# of elements to sort]]

As usual, comments, critics, bug reports and ideas for possible improvements are welcome!


JK
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: New array features

Post by MrSwiss »

@Juergen,

you seem to pack a double hirarchy into the enum.
I've made it single hirarchy as well, as bitfield like, meaning:
each bit (set/null) represents a specific option:

Code: Select all

enum array_enums_ explicit                            'keywords for array features
  sort    = 1                                         'sort array
    up
    down
  sort2

  ins     = 10                                        'insert element

  del     = 20                                        'delete element

  scan    = 30                                        'scan array (perform a search)

  info    = 40                                        'get descriptor information
   data                                               'pointer to the first array element in memory
   dimensions                                         '# of dimensions (same as UBOUND(array, 0)
   totalsize                                          'in bytes
   totalcount                                         'total # of elements in all dimensions
   size                                               'same as sizeof(array)

  calc    = 50                                        'calculate an elements linear # from indices (multiple dimensions)
 
  at      = 60                                        'dim an overlay array at a memory location (don´t initialize)
  reset                                               'erase it again, but leave the underlying memory untouched
 
' ...
end Enum

' I'd do it as below (sort of bitfield):
enum array_enums_ explicit
    ' first block
    sort_up = &h0000
    sort_dn = &h0001
    sort_cm = &h0002    ' custom sort
    ' next (single statements)
    ins     = &h0010
    del     = &h0020
    scan    = &h0040
    calc    = &h0080
    at      = &h0100
    reset   = &h0200
    ' next block
    i_data  = &H0400
    i_dims  = &h0800
    i_ttsiz = &h1000
    i_siz   = &h2000
    i_ttcnt = &h4000
    ' ...
End Enum
Juergen Kuehlwein
Posts: 284
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Post by Juergen Kuehlwein »

@MrSwiss,


generally i like it tidy and clear, therefore i grouped the enums in logical entities. This isn´t necessary at all, because you can use the enums instead of their value for comparing (that´s what they are for). Their actual value is immaterial in this case, but to me it looks more tidy this way. As far as i can tell by now, i don´t need bitmasks, but i know i could arrange it as you proposed.

Thanks,


JK
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: New array features

Post by MrSwiss »

Sorry, but I don't think it tidy, clear or intuitive, to follow.

Another method would be:

Code: Select all

enum array_enums_ explicit
    ' sorting
    sort_up = 0
    sort_dn
    sort_cm             ' custom sort
    ' manipulating
    a_ins
    a_del
    a_scan
    a_calc
    a_at
    a_reset
    ' informations
    i_data
    i_dims
    i_ttsiz
    i_siz
    i_ttcnt
End Enum
Another tip, don't use reserved 'key-words', even in a namespace, if
you want to be certain, to never get into conflicting 'name' problems.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: New array features

Post by Tourist Trap »

Juergen Kuehlwein wrote:Ok, next try...

Code: Select all

array(sort, a, up, 1, 5)
As usual, comments, critics, bug reports and ideas for possible improvements are welcome!
Hi JK,

I don't feel at ease at this point with this. Just in case you didn't already put this form away for any reasons, I would ideally return to this:

array2 = array_function(array1, action, specifier, range, ...whatever... )

It has the advantage to leave away the macro expansion issue at debug time. You can keep your original array untouched if you want.

The problem is that a function doesn't return an array today (and we have no simple assignement). I believed that you solved this affair by the use of the array descriptors. If you did, why not using such a classical approach compared to macros? And if you did not yet, my wish at this hour would be that you could provide us something in this direction.

If you give me a way to write something like "array" = f("array"), I can see how to implement the actions that you are thinking of (in a lesser quality of course). I still don't see if (bringing us array as return value via descriptors) it's something already done, or a todo, or something that you weren't working at for the moment.

So, to summarize my personnal need, array1 = f(array2), and array1 = array2. Provided those 2 features, I would be happy enough.

Thank you.
Juergen Kuehlwein
Posts: 284
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Post by Juergen Kuehlwein »

FB doesn´t allow for an array to be returned by a function, but you can pass an array to a function and modify it in this function. Having an array descriptor you could manipulate, doesn´t mean you could return an array!

More syntax examples:

array(sort, a, up) would sort the entire array a() in ascending order
array(sort, a, up, 10) would sort array a() in ascending order beginning with the element at index 10
array(sort, a, up, 2, 5) would sort array a() in ascending order beginning with the element at index 2 for 5 elements
array(sort, a, down) would sort the entire array a() in descending order
array(sort, a, @customsort, 10) would sort array a() using a custom sort procedure beginning with the element at index 10
array(sort, (a, b), up) would sort the entire array a() in ascending order, array b() gets sorted in the exact same order as a()

in any case a() itself is sorted, the return value indicates error or success.


array(info, a, data) would return the memory address of the first array element of array a()
array(info, a, totalcount) would return the number of all elements in all dimensions of array a()
...

in this case the information held in the array´s descriptor is made available at all, or in a more comfortable way


So the overall syntax is:

array(...) -> do something with an array
array(action-verb, ...) -> specify the basic action
array(action-verb, a, ...) -> array
array(action-verb, a, specifier [, ...]) -> specify the exact action, more parameters may follow as needed

I don´t know of any other method than using macros for getting the necessary flexibility. In the end you must get an array of unknown type into a function for further RTL processing.

Apart form "array" (which seems obvious) we can discuss the names. I tried to take very unusual or unlikely names (except for "array") in the global namespace, all other names are inside a separate namespace or guarded by scope blocks.


Some more thoughts about this topic:

Exposing the array descriptor to the user would mean, that future changes of this descriptor might break user code relying on it. Fxm´s definition is correct, as far as i can tell, but it´s an undocumented and unofficial feature and thus subject to change. There are still some problems with arrays in FB in general, e.g. you can REDIM a fixed size array passed as a procedure parameter, this shouldn´t be possible and raise a compiler error, but currently the array descriptor doesn´t tell us, if an array is of fixed size or dynamic.

Therefore i think, it would be a wiser decision not to expose the descriptor itself, but to supply a method of retrieving it´s content (as far as not available yet). This way possible future changes of the descriptor will not necessarily break user code based on these new methods.


JK
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: New array features

Post by Tourist Trap »

Juergen Kuehlwein wrote:FB doesn´t allow for an array to be returned by a function, but you can pass an array to a function and modify it in this function. Having an array descriptor you could manipulate, doesn´t mean you could return an array!
Yes, I thought a couple of minutes that you changed this facts.

Appart sorting, what are the other actions planned? Something like shuffle and so on I suppose. Or we'll see all that in time I guess :)

Thanks.
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: New array features

Post by Lost Zergling »

@Tourist Trap. There are several severe technical difficulties to foresee: how to standardize the access to the data of the table? What syntax for functions? How to run the same syntax on different types of data without having to include a micro-runtime? And so on. In the case of an instruction set the technical issues are also present: where to put the 'error handling' and how is it handled? (in the parser? no, forbidden, especially not in the parser, ..) What persistence and what level of automaticity for the underlying management of indexes? What logic for the consistency of the instruction set? We must analyze the issues and not underestimate them. In comparison, a function can not return an array is not a very serious problem, I think. It is always very difficult to thank someone while asking for specifications without seeming to give instructions. You were one of the rare people to thank me ("this nice tool"). The person who opens a free code has his own motivations, the best way to thank is to use it when the time comes. In any case, this is my opinion.

@Juergen Kuehlwein :
array(info, a, data) would return the memory address of the first array element of array a()
If not the case in the syntax above
array(info, a, @linearsequence or anykwd) would return the memory address of the memory address of the first array element of array a() for variable length datas. May need that one otherwise we might encounter a regression in what it is possible doing with FB, especially if this feature is becoming "out of the standard feature".
Last edited by Lost Zergling on May 26, 2019 20:51, edited 4 times in total.
Post Reply